Module: Enumerize::ActiveRecordSupport
- Defined in:
- lib/enumerize/activerecord.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
Instance Method Details
#enumerize(name, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/enumerize/activerecord.rb', line 3 def enumerize(name, ={}) super _enumerize_module.dependent_eval do if self < ::ActiveRecord::Base include InstanceMethods # Since Rails use `allocate` method on models and initializes them with `init_with` method. # This way `initialize` method is not being called, but `after_initialize` callback always gets triggered. after_initialize :_set_default_value_for_enumerized_attributes # https://github.com/brainspec/enumerize/issues/111 require 'enumerize/hooks/uniqueness' end end end |