Module: EnumerateIt::ClassMethods

Defined in:
lib/enumerate_it/class_methods.rb

Instance Method Summary collapse

Instance Method Details

#has_enumeration_for(attribute, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/enumerate_it/class_methods.rb', line 4

def has_enumeration_for(attribute, options = {})
  self.enumerations = self.enumerations.dup

  define_enumeration_class attribute, options
  set_validations attribute, options
  create_enumeration_humanize_method options[:with], attribute
  store_enumeration options[:with], attribute

  if options[:create_helpers]
    create_helper_methods options[:with], attribute, options[:create_helpers]
    create_mutator_methods options[:with], attribute, options[:create_helpers]
  end

  if options[:create_scopes]
    create_scopes options[:with], attribute
  end
end