Parent

RubiGen::GeneratedAttribute

Attributes

name[RW]
type[RW]
column[RW]

Public Class Methods

new(name, type) click to toggle source
    # File lib/rubigen/generated_attribute.rb, line 7
 7:     def initialize(name, type)
 8:       @name, @type = name, type.to_sym
 9:       @column = ActiveRecord::ConnectionAdapters::Column.new(name, nil, @type)
10:     end

Public Instance Methods

default() click to toggle source
    # File lib/rubigen/generated_attribute.rb, line 25
25:     def default
26:       @default ||= case type
27:         when :integer                     then 1
28:         when :float                       then 1.5
29:         when :decimal                     then "9.99"
30:         when :datetime, :timestamp, :time then Time.now.to_s(:db)
31:         when :date                        then Date.today.to_s(:db)
32:         when :string                      then "MyString"
33:         when :text                        then "MyText"
34:         when :boolean                     then false
35:         else
36:           ""
37:       end      
38:     end
field_type() click to toggle source
    # File lib/rubigen/generated_attribute.rb, line 12
12:     def field_type
13:       @field_type ||= case type
14:         when :integer, :float, :decimal   then :text_field
15:         when :datetime, :timestamp, :time then :datetime_select
16:         when :date                        then :date_select
17:         when :string                      then :text_field
18:         when :text                        then :text_area
19:         when :boolean                     then :check_box
20:         else
21:           :text_field
22:       end      
23:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.