Class: Flattener::NestedConfigurator
- Inherits:
-
Configurator
- Object
- Configurator
- Flattener::NestedConfigurator
- Defined in:
- lib/flattener/configurator.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Attributes inherited from Configurator
#accessor, #flattened_attrs, #klass, #name, #options, #prefix
Instance Method Summary collapse
-
#initialize(parent, name, options = {}, &block) ⇒ NestedConfigurator
constructor
A new instance of NestedConfigurator.
- #prepare! ⇒ Object
Methods inherited from Configurator
#accessor_method_name, #add_build_method!, #add_proxy_method!, #add_validator_method!, #attribute, #attributes, #build_method_name, #flat, flat, #mass_assignment_is_supported?, #method_name_for, #module_included?, #proxy_method_name, #validate_method_name, #validations_are_supported?
Constructor Details
#initialize(parent, name, options = {}, &block) ⇒ NestedConfigurator
Returns a new instance of NestedConfigurator.
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/flattener/configurator.rb', line 147 def initialize(parent, name, = {}, &block) @parent = parent [:prefix] ||= if @parent.prefix.blank? name.to_s else "#{@parent.prefix}_#{name.to_s}" end [:accessor] ||= "#{parent.accessor_method_name}_#{name}" super(parent.klass, name, , &block) end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
145 146 147 |
# File 'lib/flattener/configurator.rb', line 145 def parent @parent end |
Instance Method Details
#prepare! ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/flattener/configurator.rb', line 158 def prepare! super code = <<-CODE # customer_payment_profile_address def #{parent.accessor_method_name}_#{name} #{parent.proxy_method_name}.#{name} end CODE @klass.class_eval code end |