Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/base.rb
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #read_attribute(method_name) ⇒ Object
- #write_attribute(method_name, value) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 |
# File 'lib/active_record/base.rb', line 5 def initialize(attributes={}) attributes.each do |key, value| self.send "#{key}=".to_sym, value end end |
Instance Method Details
#read_attribute(method_name) ⇒ Object
11 12 13 |
# File 'lib/active_record/base.rb', line 11 def read_attribute(method_name) instance_variable_get "@#{method_name}" end |
#write_attribute(method_name, value) ⇒ Object
15 16 17 |
# File 'lib/active_record/base.rb', line 15 def write_attribute(method_name, value) instance_variable_set "@#{method_name}", value end |