Class: AttributesFor::Rails::AttributesForHelper::AttributeBuilder
- Inherits:
-
Object
- Object
- AttributesFor::Rails::AttributesForHelper::AttributeBuilder
- Includes:
- ActionView::Helpers, FontAwesome::Rails::IconHelper
- Defined in:
- app/helpers/attributes_for/rails/attributes_for_helper.rb
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#object ⇒ Object
Returns the value of attribute object.
-
#options ⇒ Object
Returns the value of attribute options.
-
#template ⇒ Object
Returns the value of attribute template.
-
#wrappers ⇒ Object
Returns the value of attribute wrappers.
Instance Method Summary collapse
-
#initialize(object, template, options = {}) ⇒ AttributeBuilder
constructor
A new instance of AttributeBuilder.
- #method_missing(method, *args, &block) ⇒ Object
- #string(label, options = {}, &block) ⇒ Object
Constructor Details
#initialize(object, template, options = {}) ⇒ AttributeBuilder
Returns a new instance of AttributeBuilder.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 16 def initialize(object, template, = {}) = .dup @object = object @template = template @default_options = [:defaults] || {} @wrappers = { label: 'span', value: 'span' } @wrappers.merge!(.delete(:wrappers)) if .key?(:wrappers) @empty = .delete(:empty) if .key?(:empty) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
28 29 30 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 28 def method_missing(method, *args, &block) build_content(method, *args, &block) end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
13 14 15 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 13 def @default_options end |
#object ⇒ Object
Returns the value of attribute object.
13 14 15 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 13 def object @object end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 13 def @options end |
#template ⇒ Object
Returns the value of attribute template.
13 14 15 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 13 def template @template end |
#wrappers ⇒ Object
Returns the value of attribute wrappers.
13 14 15 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 13 def wrappers @wrappers end |
Instance Method Details
#string(label, options = {}, &block) ⇒ Object
32 33 34 |
# File 'app/helpers/attributes_for/rails/attributes_for_helper.rb', line 32 def string(label, = {}, &block) wrap_content(label, template.capture(&block), ) end |