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
40 41 42 43 44 |
# File 'lib/active_data/model/representation.rb', line 40 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
46 47 48 49 50 |
# File 'lib/active_data/model/representation.rb', line 46 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
33 34 35 36 37 38 |
# File 'lib/active_data/model/representation.rb', line 33 def represents(*names, &block) = names. names.each do |name| add_attribute(ActiveData::Model::Attributes::Reflections::Represents, name, , &block) end end |