Class: Rails::Generator::GeneratedAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/datamapper4rails/rspec_default_values.rb

Instance Method Summary collapse

Instance Method Details

#default_valueObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/datamapper4rails/rspec_default_values.rb', line 7

def default_value
  @default_value ||= case type
    when :int, :integer               then "1"
    when :float                       then "1.5"
    when :decimal, :big_decimal       then "9.99"
    when :date_time, :datetime,
                    :timestamp, :time then "Time.now"
    when :date                        then "Date.today"
    when :string, :text               then "\"value for #{@name}\""
    when :boolean                     then "false"
    else
      ""
  end
end