Class: Yauth::User
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#plain_password ⇒ Object
Returns the value of attribute plain_password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #authenticate(password) ⇒ Object
-
#initialize(hash = {}) ⇒ User
constructor
A new instance of User.
- #to_hash ⇒ Object
- #to_yaml(opts = {}) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ User
Returns a new instance of User.
9 10 11 12 13 14 15 |
# File 'lib/yauth/user.rb', line 9 def initialize(hash={}) hash = hash[:user] if hash[:user] hash = hash["user"] if hash["user"] self.username = hash[:username] || hash["username"] self.password = hash[:password] || hash["password"] end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/yauth/user.rb', line 6 def password @password end |
#plain_password ⇒ Object
Returns the value of attribute plain_password.
7 8 9 |
# File 'lib/yauth/user.rb', line 7 def plain_password @plain_password end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/yauth/user.rb', line 6 def username @username end |
Instance Method Details
#authenticate(password) ⇒ Object
30 31 32 33 |
# File 'lib/yauth/user.rb', line 30 def authenticate(password) return false if password.to_s == "" self.password == password end |
#to_hash ⇒ Object
22 23 24 |
# File 'lib/yauth/user.rb', line 22 def to_hash { "user" => { "username" => username, "password" => password } } end |
#to_yaml(opts = {}) ⇒ Object
26 27 28 |
# File 'lib/yauth/user.rb', line 26 def to_yaml(opts={}) to_hash.to_yaml(opts) end |