Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created June 16, 2013 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejarvis/5791877 to your computer and use it in GitHub Desktop.
Save leejarvis/5791877 to your computer and use it in GitHub Desktop.
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