Class: Entity::Base
- Inherits:
-
Object
- Object
- Entity::Base
- Defined in:
- lib/entity_rb/base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #fields ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
3 4 5 6 7 |
# File 'lib/entity_rb/base.rb', line 3 def initialize(attributes={}) attributes.each do |key, value| send("#{key}=", value) if fields.include? key.to_sym end end |
Class Method Details
.fields ⇒ Object
19 20 21 |
# File 'lib/entity_rb/base.rb', line 19 def self.fields @fields end |
Instance Method Details
#attributes ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/entity_rb/base.rb', line 9 def attributes hash = {} fields.each do |key| hash[key.to_sym] = self.send(key) end hash end |
#fields ⇒ Object
23 24 25 |
# File 'lib/entity_rb/base.rb', line 23 def fields self.class.fields end |