Class: CoderWally::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/coder_wally/account.rb

Overview

Stores the users accounts

Instance Method Summary collapse

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 |, value|
    create_accessor 
    set_accessor_value , 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