Class: Entity
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Entity
- Defined in:
- lib/entity.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Entity
constructor
A new instance of Entity.
Constructor Details
#initialize(attributes = {}) ⇒ Entity
Returns a new instance of Entity.
4 5 6 7 8 9 10 11 |
# File 'lib/entity.rb', line 4 def initialize(attributes = {}) super(attributes) self.class.ensured_attributes.each do |key| unless attributes.has_key?(key) self.public_send("#{key}=", nil) end end end |
Class Method Details
.ensure_attributes(*attribute_names) ⇒ Object
14 15 16 17 |
# File 'lib/entity.rb', line 14 def ensure_attributes(*attribute_names) @ensured_attributes ||= Set.new @ensured_attributes.merge(attribute_names) end |
.ensured_attributes ⇒ Object
19 20 21 |
# File 'lib/entity.rb', line 19 def ensured_attributes @ensured_attributes ||= Set.new end |