Class: LocastyleComponents::Forms::SwitchButton

Inherits:
Base
  • Object
show all
Defined in:
lib/locastyle_components/forms/switch_button.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#i18n?, #i18n_attr

Constructor Details

#initialize(form, view, attribute, options) ⇒ SwitchButton

Returns a new instance of SwitchButton.



10
11
12
13
14
15
16
17
18
# File 'lib/locastyle_components/forms/switch_button.rb', line 10

def initialize(form, view, attribute, options)
  @form = form
  @view = view
  @attribute = attribute.to_s
  @options = Hash(options)

  @object = form.object
  @klass = object.class.name.underscore
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def attribute
  @attribute
end

#formObject

Returns the value of attribute form.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def form
  @form
end

#klassObject

Returns the value of attribute klass.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def klass
  @klass
end

#objectObject

Returns the value of attribute object.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def object
  @object
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def options
  @options
end

#viewObject

Returns the value of attribute view.



8
9
10
# File 'lib/locastyle_components/forms/switch_button.rb', line 8

def view
  @view
end

Instance Method Details

#buildObject



20
21
22
23
# File 'lib/locastyle_components/forms/switch_button.rb', line 20

def build
  return label + switch if use_label?
  switch
end