Class: AttributesFor::Rails::AttributesForHelper::AttributeBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers
Defined in:
app/helpers/attributes_for/rails/attributes_for_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, template) ⇒ AttributeBuilder

Returns a new instance of AttributeBuilder.



14
15
16
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 14

def initialize(object, template)
  @object, @template = object, template
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



22
23
24
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 22

def method_missing(m, *args, &block)
  build_content(m, *args, &block)
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



12
13
14
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 12

def object
  @object
end

#templateObject

Returns the value of attribute template.



12
13
14
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 12

def template
  @template
end

Instance Method Details

#string(label, options = {}, &block) ⇒ Object



18
19
20
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 18

def string(label, options = {}, &block)
  wrap_content(" #{label}: " + template.capture(&block), options)
end