lib/coder_wally/account.rb in coder_wally-0.1.1 vs lib/coder_wally/account.rb in coder_wally-0.1.2
- old
+ new
@@ -3,11 +3,19 @@
# Stores the users accounts
class Account
# Dynamically create account properties
def initialize(collection_of_accounts)
collection_of_accounts.each do |account, value|
- singleton_class.class_eval { attr_accessor "#{account}" }
- instance_variable_set("@#{account}", value)
+ create_accessor account
+ set_accessor_value account, value
end
+ end
+ # create the attribute accessor
+ def create_accessor(name)
+ singleton_class.class_eval { attr_accessor "#{name}" }
+ end
+ # assign the value to the accessor
+ def set_accessor_value(name, value)
+ instance_variable_set("@#{name}", value)
end
end
end