Class: Erector::RailsFormBuilder
- Defined in:
- lib/erector/rails/rails_form_builder.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(object_name, object, template, options, proc) ⇒ RailsFormBuilder
constructor
A new instance of RailsFormBuilder.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(object_name, object, template, options, proc) ⇒ RailsFormBuilder
Returns a new instance of RailsFormBuilder.
5 6 7 8 |
# File 'lib/erector/rails/rails_form_builder.rb', line 5 def initialize(object_name, object, template, , proc) @template = template @parent = ActionView::Base.default_form_builder.new(object_name, object, template, , proc) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/erector/rails/rails_form_builder.rb', line 10 def method_missing(method_name, *args, &block) if parent.respond_to?(method_name) return_value = parent.send(method_name, *args, &block) if return_value.is_a?(String) template.concat(return_value) nil else return_value end else super end end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/erector/rails/rails_form_builder.rb', line 3 def parent @parent end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'lib/erector/rails/rails_form_builder.rb', line 3 def template @template end |