Module: ActiveData::Model::Representation::ClassMethods

Defined in:
lib/active_data/model/representation.rb

Instance Method Summary collapse

Instance Method Details

#represented_attributesObject



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_aliasesObject



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)
  options = names.extract_options!
  names.each do |name|
    add_attribute(ActiveData::Model::Attributes::Reflections::Represents, name, options, &block)
  end
end