Module: HasEnumeration::Arel::TableExtensions

Defined in:
lib/has_enumeration/arel/table_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/has_enumeration/arel/table_extensions.rb', line 4

def self.included(base)
  base.class_eval do
    alias_method_chain :attributes, :has_enumeration

    def self.has_enumeration_mappings
      @has_enumeration_mappings ||= Hash.new {|h,k| h[k] = Hash.new}
    end
  end
end

Instance Method Details

#attributes_with_has_enumerationObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/has_enumeration/arel/table_extensions.rb', line 14

def attributes_with_has_enumeration
  return @attributes if @attributes
  attrs = attributes_without_has_enumeration
  mappings = self.class.has_enumeration_mappings[name]
  if mappings
    mappings.each do |attr_name, mapping|
      attr = attrs[attr_name]
      install_has_enumeration_attribute_mapping(attr, mapping)
    end
  end
  attrs
end