Class: E9Rails::ActiveRecord::InheritableOptions::Options
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- E9Rails::ActiveRecord::InheritableOptions::Options
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation
- Defined in:
- lib/e9_rails/active_record/inheritable_options.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Class Method Summary collapse
Instance Method Summary collapse
-
#extractable_options? ⇒ Boolean
This is for active_support, signifying that this class shouldn’t be extracted from *args as options via extract_options.
-
#initialize(hash, base) ⇒ Options
constructor
A new instance of Options.
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. = Hash[self] self[k] end end end end |
Instance Attribute Details
#base ⇒ Object (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_scope ⇒ Object
173 |
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 173 def i18n_scope; :activerecord end |
.name ⇒ Object
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.
179 180 181 |
# File 'lib/e9_rails/active_record/inheritable_options.rb', line 179 def false end |