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.



410
411
412
413
414
415
416
# File 'lib/sandals/view.rb', line 410

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.



408
409
410
# File 'lib/sandals/view.rb', line 408

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



408
409
410
# File 'lib/sandals/view.rb', line 408

def label
  @label
end

Instance Method Details

#change(checked) ⇒ Object



422
423
424
# File 'lib/sandals/view.rb', line 422

def change(checked)
  execute_action(checked)
end

#checked?Boolean

Returns:

  • (Boolean)


418
419
420
# File 'lib/sandals/view.rb', line 418

def checked?
  @checked
end