Class: Mugatu::Entity
- Inherits:
-
Object
- Object
- Mugatu::Entity
- Defined in:
- lib/mugatu/entity.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(attributes = {}) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(attributes = {}) ⇒ Entity
Returns a new instance of Entity.
16 17 18 19 20 |
# File 'lib/mugatu/entity.rb', line 16 def initialize(attributes = {}) self.attributes.each do |a| send("#{a.key}=", attributes[a.key]) if attributes.key?(a.key) end end |
Class Method Details
.attribute(key, type, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/mugatu/entity.rb', line 3 def self.attribute(key, type, = {}) attribute = Attribute.new(key, type, ) define_attribute_reader(attribute) define_attribute_writer(attribute) attributes << attribute end |
.attributes ⇒ Object
12 13 14 |
# File 'lib/mugatu/entity.rb', line 12 def self.attributes @attributes ||= [] end |
Instance Method Details
#attributes ⇒ Object
22 23 24 |
# File 'lib/mugatu/entity.rb', line 22 def attributes self.class.attributes end |