Class: Satis::Switch::Component
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Satis::Switch::Component
- Defined in:
- app/components/satis/switch/component.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from ApplicationComponent
Instance Method Summary collapse
-
#initialize(form:, attribute:, **options, &block) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationComponent
Constructor Details
#initialize(form:, attribute:, **options, &block) ⇒ Component
Returns a new instance of Component.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/components/satis/switch/component.rb', line 8 def initialize(form:, attribute:, **, &block) super @form = form @attribute = attribute @options = @block = block @icon = true @icon = [:icon] if .key?(:icon) @value = .key?(:value) ? [:value] : @form.object.send(attribute) @value = @value == '0' || !@value ? false : true [:input_html] ||= {} [:input_html] = { data: { 'satis-switch-target' => 'hiddenInput' } }.deep_merge([:input_html]) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'app/components/satis/switch/component.rb', line 6 def attribute @attribute end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
6 7 8 |
# File 'app/components/satis/switch/component.rb', line 6 def form @form end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
6 7 8 |
# File 'app/components/satis/switch/component.rb', line 6 def icon @icon end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'app/components/satis/switch/component.rb', line 6 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'app/components/satis/switch/component.rb', line 6 def url @url end |