Class: Wizardly::Wizard::PageField

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ PageField

Returns a new instance of PageField.



40
41
42
43
44
# File 'lib/wizardly/wizard/page.rb', line 40

def initialize(name, type)
  @name = name
  @column_type = type.to_sym
  @field_type = nil
end

Instance Attribute Details

#column_typeObject (readonly)

Returns the value of attribute column_type.



38
39
40
# File 'lib/wizardly/wizard/page.rb', line 38

def column_type
  @column_type
end

#nameObject (readonly)

Returns the value of attribute name.



38
39
40
# File 'lib/wizardly/wizard/page.rb', line 38

def name
  @name
end

Instance Method Details

#field_typeObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wizardly/wizard/page.rb', line 46

def field_type
  @field_type ||= case @column_type
  when :string                      then :text_field
  when :password                    then :password_field
  when :enum                        then :enum_select
  when :text                        then :text_area
  when :boolean                     then :check_box
  when :integer, :float, :decimal   then :text_field
  when :datetime, :timestamp, :time then :datetime_select
  when :date                        then :date_select
  else
    :text_field
  end
end