Class Index [+]

Quicksearch

Sequel::Plugins::IdentityMap::InstanceMethods

Public Instance Methods

delete() click to toggle source

Remove instances from the identity map cache if they are deleted.

     # File lib/sequel/plugins/identity_map.rb, line 205
205:         def delete
206:           super
207:           if idm = model.identity_map
208:             idm.delete(model.identity_map_key(pk))
209:           end
210:           self
211:         end
merge_db_update(row) click to toggle source

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 215
215:         def merge_db_update(row)
216:           @values = row.merge(@values)
217:         end

Private Instance Methods

_associated_object_pk(fk) click to toggle source

The primary keys values of the associated object, given the foreign key columns(s).

     # File lib/sequel/plugins/identity_map.rb, line 223
223:         def _associated_object_pk(fk)
224:           fk.is_a?(Array) ? fk.map{|c| send(c)} : send(fk)
225:         end
_load_associated_object(opts, dynamic_opts) click to toggle source

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 231
231:         def _load_associated_object(opts, dynamic_opts)
232:           klass = opts.associated_class
233:           cache_lookup = opts.fetch(:idm_cache_lookup) do 
234:             opts[:idm_cache_lookup] = klass.respond_to?(:identity_map) &&
235:               opts[:type] == :many_to_one &&
236:               opts[:key] &&
237:               opts.primary_key == klass.primary_key
238:           end
239:           if cache_lookup &&
240:             !dynamic_opts[:callback] &&
241:             (idm = klass.identity_map) &&
242:             (o = idm[klass.identity_map_key(_associated_object_pk(opts[:key]))])
243:             o
244:           else
245:             super
246:           end
247:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.