Class: Materialize::Entity
- Inherits:
-
Object
- Object
- Materialize::Entity
- Includes:
- Utils
- Defined in:
- lib/materialize/entity.rb
Instance Attribute Summary collapse
-
#__builder_info__ ⇒ Object
writeonly
Sets the attribute builder_info.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Entity
constructor
A new instance of Entity.
Methods included from Utils
Constructor Details
#initialize(attributes) ⇒ Entity
Returns a new instance of Entity.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/materialize/entity.rb', line 13 def initialize(attributes) raise "Attributes must be a hash" unless attributes.is_a?(Hash) @__repo__ = attributes[:__repo__] = attributes[:__options__] attributes.delete(:__repo__) attributes.delete(:__options__) attributes.each_pair do |key, value| value = attempt_entity_conversion(key, value) if collection?(value) instance_variable_set("@#{key}", value) (class << self; self; end).class_eval do attr_reader key.to_sym end end end |
Instance Attribute Details
#__builder_info__=(value) ⇒ Object (writeonly)
Sets the attribute builder_info
11 12 13 |
# File 'lib/materialize/entity.rb', line 11 def __builder_info__=(value) @__builder_info__ = value end |
Class Method Details
.wrap(entities_data) ⇒ Object
7 8 9 |
# File 'lib/materialize/entity.rb', line 7 def self.wrap(entities_data) entities_data.map { |entity_data| new(entity_data) } end |