Class: Authenticator::Client::Account
- Inherits:
-
Object
- Object
- Authenticator::Client::Account
- Defined in:
- lib/authenticator/client/account.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params, password = nil) ⇒ Account
constructor
A new instance of Account.
- #new_initialize(params) ⇒ Object
- #old_initialize(username, password) ⇒ Object
- #to_params ⇒ Object (also: #to_h)
Constructor Details
#initialize(params, password = nil) ⇒ Account
Returns a new instance of Account.
5 6 7 8 9 10 11 |
# File 'lib/authenticator/client/account.rb', line 5 def initialize(params, password=nil) if password.nil? new_initialize(params) else old_initialize(params, password) end end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/authenticator/client/account.rb', line 4 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/authenticator/client/account.rb', line 4 def id @id end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/authenticator/client/account.rb', line 4 def password @password end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/authenticator/client/account.rb', line 4 def updated_at @updated_at end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/authenticator/client/account.rb', line 4 def username @username end |
Class Method Details
.from_json(json) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/authenticator/client/account.rb', line 26 def self.from_json(json) params = json.each_with_object({}) do |(key, value), hash| hash[key.to_sym] = value end new(params) end |
Instance Method Details
#new_initialize(params) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/authenticator/client/account.rb', line 13 def new_initialize(params) @id = params[:id] @username = params[:username] @password = params[:password] @created_at = params[:created_at] @updated_at = params[:updated_at] end |
#old_initialize(username, password) ⇒ Object
21 22 23 24 |
# File 'lib/authenticator/client/account.rb', line 21 def old_initialize(username, password) @username = username @password = password end |
#to_params ⇒ Object Also known as: to_h
33 34 35 36 37 38 39 40 |
# File 'lib/authenticator/client/account.rb', line 33 def to_params { account: { username: username, password: password } } end |