Class: Dailycred::User
- Inherits:
-
Object
- Object
- Dailycred::User
- Includes:
- ActiveModel::Serialization, ActiveModel::Validations
- Defined in:
- lib/dailycred/user.rb
Instance Attribute Summary collapse
-
#authorized ⇒ Object
Returns the value of attribute authorized.
-
#client ⇒ Object
Returns the value of attribute client.
-
#email ⇒ Object
Returns the value of attribute email.
-
#pass ⇒ Object
Returns the value of attribute pass.
Instance Method Summary collapse
-
#initialize(client, user = {}) ⇒ User
constructor
A new instance of User.
- #login ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(client, user = {}) ⇒ User
Returns a new instance of User.
10 11 12 13 14 15 16 |
# File 'lib/dailycred/user.rb', line 10 def initialize client, user = {} self.client = client self. = false user.each do |k,v| self[k] = v if self.respond_to(k) end end |
Instance Attribute Details
#authorized ⇒ Object
Returns the value of attribute authorized.
8 9 10 |
# File 'lib/dailycred/user.rb', line 8 def @authorized end |
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/dailycred/user.rb', line 8 def client @client end |
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/dailycred/user.rb', line 8 def email @email end |
#pass ⇒ Object
Returns the value of attribute pass.
8 9 10 |
# File 'lib/dailycred/user.rb', line 8 def pass @pass end |
Instance Method Details
#login ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dailycred/user.rb', line 18 def login if !self.valid? #it didn't work already, return false return false end response = JSON.parse client.login(self.to_hash) err_parser response return false if !self.valid? true end |
#to_hash ⇒ Object
31 32 33 34 35 36 |
# File 'lib/dailycred/user.rb', line 31 def to_hash { :email => self.email, :pass => self.pass } end |