Method: EnumTable::Record::ClassMethods#expand_attribute_names_for_aggregates

Defined in:
lib/enum_table/record.rb

#expand_attribute_names_for_aggregates(attribute_names) ⇒ Object

Enables .find_by_name(value) for enums.



138
139
140
141
142
143
144
145
# File 'lib/enum_table/record.rb', line 138

def expand_attribute_names_for_aggregates(attribute_names)  # :nodoc:
  attribute_names = super
  enums.each do |name, reflection|
    index = attribute_names.index(name) and
      attribute_names[index] = reflection.id_name
  end
  attribute_names
end