Class: SimpleAttribute::Attributes::Enumeration
- Defined in:
- lib/simple_attribute/attributes/enumeration.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #options, #record, #value
Instance Method Summary collapse
-
#attribute_name ⇒ Object
Attribute name.
-
#label_method ⇒ Object
Link label method.
-
#render ⇒ Object
Render attribute.
Methods inherited from Base
#default_value, #defaults, #html_options, #initialize, #method_missing, #render_attribute, #render_default_value, #render_with_default, #render_wrapper, #renderer_name, #value?, #wrapper, #wrapper?, #wrapper_html
Constructor Details
This class inherits a constructor from SimpleAttribute::Attributes::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SimpleAttribute::Attributes::Base
Instance Method Details
#attribute_name ⇒ Object
Attribute name
5 6 7 |
# File 'lib/simple_attribute/attributes/enumeration.rb', line 5 def attribute_name 'enumeration' end |
#label_method ⇒ Object
Link label method
10 11 12 |
# File 'lib/simple_attribute/attributes/enumeration.rb', line 10 def label_method @options.fetch(:label, :titleize) end |
#render ⇒ Object
Render attribute
15 16 17 18 19 20 |
# File 'lib/simple_attribute/attributes/enumeration.rb', line 15 def render values = @value.to_a.map(&:"#{label_method}") items = values.map { |item| @value = item; super } items.join.html_safe end |