Module: ActiveData::Model::Representation::ClassMethods
- Defined in:
- lib/active_data/model/representation.rb
Instance Method Summary collapse
- #represented_attributes ⇒ Object
- #represented_names_and_aliases ⇒ Object
- #represents(*names, &block) ⇒ Object
Instance Method Details
#represented_attributes ⇒ Object
39 40 41 42 43 |
# File 'lib/active_data/model/representation.rb', line 39 def represented_attributes @represented_attributes ||= _attributes.values.select do |attribute| attribute.is_a? ActiveData::Model::Attributes::Reflections::Represents end end |
#represented_names_and_aliases ⇒ Object
45 46 47 48 49 |
# File 'lib/active_data/model/representation.rb', line 45 def represented_names_and_aliases @represented_names_and_aliases ||= represented_attributes.flat_map do |attribute| [attribute.name, *inverted_attribute_aliases[attribute.name]] end end |
#represents(*names, &block) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/active_data/model/representation.rb', line 32 def represents(*names, &block) = names. names.each do |name| add_attribute(ActiveData::Model::Attributes::Reflections::Represents, name, , &block) end end |