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.



64
65
66
67
68
69
70
71
# File 'lib/sequel/plugins/defaults_setter.rb', line 64

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