Module: Sequel::Plugins::DefaultsSetter::InstanceMethods

Defined in:
lib/sequel/plugins/defaults_setter.rb

Instance Method Summary collapse

Instance Method Details

#[](k) ⇒ Object

Use default value for a new record if values doesn't already contain an entry for it.


82
83
84
85
86
87
88
89
# File 'lib/sequel/plugins/defaults_setter.rb', line 82

def [](k)
  if new? && !values.has_key?(k)
    v = model.default_values[k]
    v.respond_to?(:call) ? v.call : v
  else
    super
  end
end