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
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.
Generated with the Darkfish Rdoc Generator 1.1.6.