Class: Erector::RailsFormBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/erector/rails/rails_form_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options, proc)
  @template = template
  @parent = ActionView::Base.default_form_builder.new(object_name, object, template, options, 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

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/erector/rails/rails_form_builder.rb', line 3

def parent
  @parent
end

#templateObject (readonly)

Returns the value of attribute template.



3
4
5
# File 'lib/erector/rails/rails_form_builder.rb', line 3

def template
  @template
end