Module: Sequel::SetOverrides

Defined in:
lib/sequel/extensions/set_overrides.rb

Instance Method Summary collapse

Instance Method Details

#set_defaults(hash) ⇒ Object

Set the default values for insert and update statements. The values hash passed to insert or update are merged into this hash, so any values in the hash passed to insert or update will override values passed to this method.

DB[:items].set_defaults(:a=>'a', :c=>'c').insert(:a=>'d', :b=>'b')
# INSERT INTO items (a, c, b) VALUES ('d', 'c', 'b')


27
28
29
# File 'lib/sequel/extensions/set_overrides.rb', line 27

def set_defaults(hash)
  clone(:defaults=>(@opts[:defaults]||{}).merge(hash))
end

#set_overrides(hash) ⇒ Object

Set values that override hash arguments given to insert and update statements. This hash is merged into the hash provided to insert or update, so values will override any values given in the insert/update hashes.

DB[:items].set_overrides(:a=>'a', :c=>'c').insert(:a=>'d', :b=>'b')
# INSERT INTO items (a, c, b) VALUES ('a', 'c', 'b')


37
38
39
# File 'lib/sequel/extensions/set_overrides.rb', line 37

def set_overrides(hash)
  clone(:overrides=>hash.merge(@opts[:overrides]||{}))
end