module Sequel::Plugins::DefaultsSetter::InstanceMethods

  1. lib/sequel/plugins/defaults_setter.rb

Methods

Public Instance

  1. []

Public Instance methods

[](k)

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

[show source]
    # File lib/sequel/plugins/defaults_setter.rb
139 def [](k)
140   if new? && !values.has_key?(k)
141     v = model.default_values.fetch(k){return}
142     if v.respond_to?(:call)
143       v = if v.respond_to?(:arity) && v.arity == 1
144         v.call(self)
145       else
146         v.call
147       end
148     end
149     values[k] = v if model.cache_default_values?
150     v
151   else
152     super
153   end
154 end