Module: Granite::Form::Model::Representation::ClassMethods
- Defined in:
- lib/granite/form/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
43 44 45 46 47 |
# File 'lib/granite/form/model/representation.rb', line 43 def represented_attributes @represented_attributes ||= _attributes.values.select do |attribute| attribute.is_a? Granite::Form::Model::Attributes::Reflections::Represents end end |
#represented_names_and_aliases ⇒ Object
49 50 51 52 53 |
# File 'lib/granite/form/model/representation.rb', line 49 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
36 37 38 39 40 41 |
# File 'lib/granite/form/model/representation.rb', line 36 def represents(*names, &block) = names. names.each do |name| add_attribute(Granite::Form::Model::Attributes::Reflections::Represents, name, , &block) end end |