Class: ParamsEditor::Field::Component
- Inherits:
-
Lookbook::BaseComponent
- Object
- Lookbook::BaseComponent
- ParamsEditor::Field::Component
- Defined in:
- app/components/lookbook/params_editor/field/component.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #field_type ⇒ Object
-
#initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs) ⇒ Component
constructor
A new instance of Component.
- #input_type ⇒ Object
- #label ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs) ⇒ Component
Returns a new instance of Component.
5 6 7 8 9 10 11 12 13 14 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 5 def initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs) @input = input @name = name @value = value @default_value = default @input_type = input_type @type = type @options = super(**html_attrs) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 3 def name @name end |
Instance Method Details
#field_type ⇒ Object
25 26 27 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 25 def field_type @input.to_s end |
#input_type ⇒ Object
29 30 31 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 29 def input_type @input_type.nil? && field_type == "text" ? "text" : @input_type end |
#label ⇒ Object
16 17 18 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 16 def label name.titleize end |
#value ⇒ Object
20 21 22 23 |
# File 'app/components/lookbook/params_editor/field/component.rb', line 20 def value val = @value.presence || @default_value @type == "Boolean" ? val == "true" || val == true : val end |