Class: Arara::CheckboxComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/checkbox_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_options, #html_tag, included

Constructor Details

#initialize(id:, name:, value: 1, checked: false, indeterminate: false, **kw) ⇒ CheckboxComponent

Returns a new instance of CheckboxComponent.



6
7
8
9
10
11
12
13
# File 'app/components/arara/checkbox_component.rb', line 6

def initialize(id:, name:, value: 1, checked: false, indeterminate: false, **kw)
  super(tag: "div", **kw)
  @checked = checked
  @indeterminate = indeterminate
  @id = id
  @name = name
  @value = value
end

Instance Attribute Details

#checkedObject (readonly)

Returns the value of attribute checked.



4
5
6
# File 'app/components/arara/checkbox_component.rb', line 4

def checked
  @checked
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'app/components/arara/checkbox_component.rb', line 4

def id
  @id
end

#indeterminateObject (readonly)

Returns the value of attribute indeterminate.



4
5
6
# File 'app/components/arara/checkbox_component.rb', line 4

def indeterminate
  @indeterminate
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'app/components/arara/checkbox_component.rb', line 4

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'app/components/arara/checkbox_component.rb', line 4

def value
  @value
end

Instance Method Details

#default_html_classObject



21
22
23
# File 'app/components/arara/checkbox_component.rb', line 21

def default_html_class
  'mdc-checkbox'
end

#html_dataObject



15
16
17
18
19
# File 'app/components/arara/checkbox_component.rb', line 15

def html_data
  data = super
  data.merge!(checked: checked, indeterminate: indeterminate)
  data
end