Methods

Enumerize::ActiveRecordSupport

Public Instance Methods

enumerize(name, options={}) click to toggle source
# File lib/enumerize/activerecord.rb, line 3
def enumerize(name, options={})
  super

  _enumerize_module.dependent_eval do
    if defined?(::ActiveRecord::Base) && self < ::ActiveRecord::Base
      if options[:scope]
        _define_scope_methods!(name, options)
      end

      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

[Validate]

Generated with the Darkfish Rdoc Generator 2.