Created
June 16, 2013 12:19
-
-
Save leejarvis/5791877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserOption < Slop::Option | |
def authenticated? | |
user = User.find_by_username(value) | |
user && user.authenticate(opts[:password]) | |
end | |
end | |
opts = Slop.parse do | |
on :user=. 'Your user name', builder: UserOption | |
on :password=, 'Your password' | |
end | |
if opts[:user].authenticated? | |
# .... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment