Class: E9Rails::ActiveRecord::InheritableOptions::Options

Inherits:
HashWithIndifferentAccess
  • Object
show all
Extended by:
ActiveModel::Naming, ActiveModel::Translation
Defined in:
lib/e9_rails/active_record/inheritable_options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, base) ⇒ Options

Returns a new instance of Options.



183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 183

def initialize(hash, base)
  merge!(hash)
  @base = base
  class << self; self; end.class_eval do
    hash.each do |k, v|
      define_method(k) { self[k] }
      define_method("#{k}=") do |v| 
        self[k] = v
        @base.options = Hash[self]
        self[k]
      end
    end
  end
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



169
170
171
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 169

def base
  @base
end

Class Method Details

.i18n_scopeObject



173
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 173

def i18n_scope; :activerecord end

.nameObject



172
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 172

def name; 'Options' end

Instance Method Details

#extractable_options?Boolean

This is for active_support, signifying that this class shouldn’t be extracted from *args as options via extract_options. If this is NOT set, we’ll get some odd errors when trying to build the form.

Returns:

  • (Boolean)


179
180
181
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 179

def extractable_options?
  false
end