Remove instances from the identity map cache if they are deleted.
# File lib/sequel/plugins/identity_map.rb, line 209 def delete super if (idm = model.identity_map) && (k = model.identity_map_key(pk)) idm.delete(k) end self end
Merge the current values into the values provided in the row, ensuring that current values are not overridden by new values.
# File lib/sequel/plugins/identity_map.rb, line 219 def merge_db_update(row) @values = row.merge(@values) end
The primary keys values of the associated object, given the foreign key columns(s).
# File lib/sequel/plugins/identity_map.rb, line 227 def _associated_object_pk(fk) fk.is_a?(Array) ? fk.map{|c| send(c)} : send(fk) end
If the association is a many_to_one and it has a :key option and the key option has a value and the association uses the primary key of the associated class as the :primary_key option, check the identity map for the associated object and return it if present.
# File lib/sequel/plugins/identity_map.rb, line 235 def _load_associated_object(opts, dynamic_opts) klass = opts.associated_class cache_lookup = opts.fetch(:idm_cache_lookup) do opts[:idm_cache_lookup] = klass.respond_to?(:identity_map) && opts[:type] == :many_to_one && opts[:key] && opts.primary_key == klass.primary_key end if cache_lookup && !dynamic_opts[:callback] && (idm = klass.identity_map) && (k = klass.identity_map_key(_associated_object_pk(opts[:key]))) && (o = idm[k]) o else super end end