Class: Sandals::Checkbox

Inherits:
Object
  • Object
show all
Includes:
Actionable, FieldValidation
Defined in:
lib/sandals/view.rb

Instance Attribute Summary collapse

Attributes included from FieldValidation

#error

Instance Method Summary collapse

Methods included from FieldValidation

#error_id, #invalid?

Constructor Details

#initialize(id, label, checked:, action:, error: nil) ⇒ Checkbox

Returns a new instance of Checkbox.



388
389
390
391
392
393
394
# File 'lib/sandals/view.rb', line 388

def initialize(id, label, checked:, action:, error: nil)
  @id = id
  @label = label.to_s
  @checked = checked
  initialize_error(error)
  @action = action
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



386
387
388
# File 'lib/sandals/view.rb', line 386

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



386
387
388
# File 'lib/sandals/view.rb', line 386

def label
  @label
end

Instance Method Details

#change(checked) ⇒ Object



400
401
402
# File 'lib/sandals/view.rb', line 400

def change(checked)
  execute_action(checked)
end

#checked?Boolean

Returns:

  • (Boolean)


396
397
398
# File 'lib/sandals/view.rb', line 396

def checked?
  @checked
end