Class: Wizard::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/wizard/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Field

Returns a new instance of Field.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wizard/field.rb', line 21

def initialize(attrs)
  attrs = attrs || {}

  @id = attrs[:id]
  @type = attrs[:type]
  @required = !!attrs[:required]
  @value = attrs[:value]
  @icon = attrs[:icon]
  @disabled = attrs[:disabled]
  @choices = []
  @show_in_sidebar = attrs[:show_in_sidebar]
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



18
19
20
# File 'lib/wizard/field.rb', line 18

def choices
  @choices
end

#disabledObject (readonly)

Returns the value of attribute disabled.



18
19
20
# File 'lib/wizard/field.rb', line 18

def disabled
  @disabled
end

#iconObject (readonly)

Returns the value of attribute icon.



18
19
20
# File 'lib/wizard/field.rb', line 18

def icon
  @icon
end

#idObject (readonly)

Returns the value of attribute id.



18
19
20
# File 'lib/wizard/field.rb', line 18

def id
  @id
end

#requiredObject (readonly)

Returns the value of attribute required.



18
19
20
# File 'lib/wizard/field.rb', line 18

def required
  @required
end

#show_in_sidebarObject (readonly)

Returns the value of attribute show_in_sidebar.



18
19
20
# File 'lib/wizard/field.rb', line 18

def show_in_sidebar
  @show_in_sidebar
end

#stepObject

Returns the value of attribute step.



19
20
21
# File 'lib/wizard/field.rb', line 19

def step
  @step
end

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/wizard/field.rb', line 18

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



18
19
20
# File 'lib/wizard/field.rb', line 18

def value
  @value
end

Instance Method Details

#add_choice(id, opts = nil) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/wizard/field.rb', line 34

def add_choice(id, opts = nil)
  choice = Choice.new(id, opts || {})
  choice.field = self

  @choices << choice
  choice
end