Module: Poppy::ActiveRecord::ClassMethods

Defined in:
lib/poppy/active_record.rb

Instance Method Summary collapse

Instance Method Details

#enumeration(attribute_name, **options) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/poppy/active_record.rb', line 23

def enumeration(attribute_name, **options)
  options.assert_valid_keys(:as, :of)
  column_type = options.fetch(:as, DEFAULT_COLUMN_TYPE)
  enumeration = options[:of]
  define_type(attribute_name: attribute_name, column_type: column_type, enumeration: enumeration)
  add_validation(attribute_name: attribute_name, column_type: column_type, enumeration: enumeration)
end