Class: Satis::Input::Component
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Satis::Input::Component
- Defined in:
- app/components/satis/input/component.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from ApplicationComponent
Instance Method Summary collapse
-
#initialize(form: nil, attribute: nil, **options) ⇒ Component
constructor
A new instance of Component.
- #input_class ⇒ Object
- #input_container_class ⇒ Object
Methods inherited from ApplicationComponent
Constructor Details
#initialize(form: nil, attribute: nil, **options) ⇒ Component
Returns a new instance of Component.
23 24 25 26 27 |
# File 'app/components/satis/input/component.rb', line 23 def initialize(form: nil, attribute: nil, **) @form = form @attribute = attribute @options = end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
15 16 17 |
# File 'app/components/satis/input/component.rb', line 15 def attribute @attribute end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
15 16 17 |
# File 'app/components/satis/input/component.rb', line 15 def form @form end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'app/components/satis/input/component.rb', line 15 def @options end |
Instance Method Details
#input_class ⇒ Object
29 30 31 |
# File 'app/components/satis/input/component.rb', line 29 def input_class [@options.fetch(:input_html, {}).fetch(:class, ""), "sts-input__input", form.has_error?(attribute) ? "is-invalid" : ""].join(" ") end |
#input_container_class ⇒ Object
33 34 35 |
# File 'app/components/satis/input/component.rb', line 33 def input_container_class form.has_error?(attribute) && "is-invalid" end |