Module: Datamappify::Entity::Composable::DSL
- Defined in:
- lib/datamappify/entity/composable.rb
Instance Method Summary collapse
- #attributes_from(entity_class, options = {}) ⇒ void
- #excluded_attributes(entity_class) ⇒ Array private
- #prefix_attribute_name!(attribute, prefix) ⇒ void private
- #tweak_attribute!(attribute, options) ⇒ Virtus::Attribute private
Instance Method Details
#attributes_from(entity_class, options = {}) ⇒ void
This method returns an undefined value.
14 15 16 17 18 19 20 |
# File 'lib/datamappify/entity/composable.rb', line 14 def attributes_from(entity_class, = {}) entity_class.attribute_set.each do |attribute| unless excluded_attributes(entity_class).include?(attribute.name) self.attribute_set << tweak_attribute!(attribute, ) end end end |
#excluded_attributes(entity_class) ⇒ Array (private)
27 28 29 |
# File 'lib/datamappify/entity/composable.rb', line 27 def excluded_attributes(entity_class) @excluded_attributes ||= entity_class.reference_keys << :id end |
#prefix_attribute_name!(attribute, prefix) ⇒ void (private)
This method returns an undefined value.
47 48 49 |
# File 'lib/datamappify/entity/composable.rb', line 47 def prefix_attribute_name!(attribute, prefix) attribute.instance_variable_set :@name, :"#{prefix}_#{attribute.name}" end |
#tweak_attribute!(attribute, options) ⇒ Virtus::Attribute (private)
36 37 38 39 40 |
# File 'lib/datamappify/entity/composable.rb', line 36 def tweak_attribute!(attribute, ) prefix_attribute_name!(attribute, [:prefix_with]) if [:prefix_with] attribute end |