Module: Sequel::Plugins::Upsert::InstanceMethods
- Defined in:
- lib/sequel/plugins/upsert.rb
Instance Attribute Summary collapse
-
#upsert_plugin_upserting ⇒ Object
readonly
dirty stateful attribute because we can’t pass any opts through to the _insert_dataset method.
Instance Method Summary collapse
Instance Attribute Details
#upsert_plugin_upserting ⇒ Object (readonly)
dirty stateful attribute because we can’t pass any opts through to the _insert_dataset method
18 19 20 |
# File 'lib/sequel/plugins/upsert.rb', line 18 def upsert_plugin_upserting @upsert_plugin_upserting end |
Instance Method Details
#upsert(opts = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sequel/plugins/upsert.rb', line 20 def upsert(opts = {}) @upsert_plugin_upserting = true if postgres? || mysql? save(opts) else manual_upsert(opts) end load_values_from_previously_inserted_object unless id self rescue Sequel::NoExistingObject load_values_from_previously_inserted_object self ensure @upsert_plugin_upserting = false end |