Class: ActionView::Helpers::AttributeBuilders::Base

Inherits:
Object
  • Object
show all
Includes:
FormOptionsHelper, Helpers::ActiveModelInstanceTag, Helpers::FormTagHelper
Defined in:
lib/actionview_attribute_builders/attribute_builders/base.rb

Overview

:nodoc:

Direct Known Subclasses

CheckBox, Label, RadioButton, Select, TextArea, TextField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_name, method_name, template_object, options = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/actionview_attribute_builders/attribute_builders/base.rb', line 12

def initialize(object_name, method_name, template_object, options = {})
  @object_name, @method_name = object_name.to_s.dup, method_name.to_s.dup
  @template_object = template_object

  @object_name.sub!(/\[\]$/, "") || @object_name.sub!(/\[\]\]$/, "]")
  @object = retrieve_object(options.delete(:object))
  @skip_default_ids = options.delete(:skip_default_ids)
  @allow_method_names_outside_object = options.delete(:allow_method_names_outside_object)
  @options = options

  if Regexp.last_match
    @generate_indexed_names = true
    @auto_index = retrieve_autoindex(Regexp.last_match.pre_match)
  else
    @generate_indexed_names = false
    @auto_index = nil
  end
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/actionview_attribute_builders/attribute_builders/base.rb', line 10

def object
  @object
end

Instance Method Details

#html_attributesObject

This is what child classes implement.

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/actionview_attribute_builders/attribute_builders/base.rb', line 32

def html_attributes
  raise NotImplementedError, "Subclasses must implement a render method"
end