Module: E9Rails::ActiveRecord::InheritableOptions::ClassMethods

Defined in:
lib/e9_rails/active_record/inheritable_options.rb

Instance Method Summary collapse

Instance Method Details

#define_method_attribute_with_inheritable_options(attr_name) ⇒ Object



64
65
66
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 64

def define_method_attribute_with_inheritable_options(attr_name)
  initialize_inheritable_options
end

#inheritable_options_initialized?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 68

def inheritable_options_initialized?
  !!@inheritable_options_initialized
end

#initialize_inheritable_optionsObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 72

def initialize_inheritable_options
  return if inheritable_options_initialized?

  self.options_class ||= self.options_parameters.present? ? Options : IndifferentOptions
  self.options_class.lookup_ancestors = lookup_ancestors

  if self.options_column
    serialized_attributes[self.options_column.to_s] = Hash
  end

  if self.delegate_options_methods
    self.options_parameters.each do |param|
      delegate param, "#{param}=", :to => :options
    end
  end

  @inheritable_options_initialized = true
end