Class: CoderWally::Account
- Inherits:
-
Object
- Object
- CoderWally::Account
- Defined in:
- lib/coder_wally/account.rb
Overview
Stores the users accounts
Instance Method Summary collapse
-
#create_accessor(name) ⇒ Object
create the attribute accessor.
-
#initialize(collection_of_accounts) ⇒ Account
constructor
Dynamically create account properties.
-
#set_accessor_value(name, value) ⇒ Object
assign the value to the accessor.
Constructor Details
#initialize(collection_of_accounts) ⇒ Account
Dynamically create account properties
6 7 8 9 10 11 |
# File 'lib/coder_wally/account.rb', line 6 def initialize(collection_of_accounts) collection_of_accounts.each do |account, value| create_accessor account set_accessor_value account, value end end |
Instance Method Details
#create_accessor(name) ⇒ Object
create the attribute accessor
13 14 15 |
# File 'lib/coder_wally/account.rb', line 13 def create_accessor(name) singleton_class.class_eval { attr_accessor "#{name}" } end |
#set_accessor_value(name, value) ⇒ Object
assign the value to the accessor
17 18 19 |
# File 'lib/coder_wally/account.rb', line 17 def set_accessor_value(name, value) instance_variable_set("@#{name}", value) end |