The default values to set in initialize for this model. A hash with column
symbol keys and default values. If the default values respond to
call
, it will be called to get the value, otherwise the value
will be used directly. You can manually modify this hash to set specific
default values, by default the ones will be parsed from the database.
Handle the CURRENT_DATE and CURRENT_TIMESTAMP values specially by returning an appropriate Date or Time/DateTime value.
# File lib/sequel/plugins/defaults_setter.rb, line 44 def convert_default_value(v) case v when Sequel::CURRENT_DATE lambda{Date.today} when Sequel::CURRENT_TIMESTAMP lambda{Sequel.datetime_class.now} else v end end
Parse the cached database schema for this model and set the default values appropriately.
# File lib/sequel/plugins/defaults_setter.rb, line 36 def set_default_values h = {} @db_schema.each{|k, v| h[k] = convert_default_value(v[:ruby_default]) unless v[:ruby_default].nil?} if @db_schema @default_values = h end