module Praxis::Mapper::SequelCompat
Public Instance Methods
_load_associated_objects(opts, dynamic_opts=OPTS)
click to toggle source
Calls superclass method
# File lib/praxis-mapper/sequel_compat.rb, line 52 def _load_associated_objects(opts, dynamic_opts=OPTS) return super if self.identity_map.nil? target = opts.associated_class key = opts[:key] case opts[:type] when :many_to_one val = if key.kind_of?(Array) @values.values_at(*key) else @values[key] end return nil if val.nil? self.identity_map.get(target, target.primary_key => val) when :one_to_many self.identity_map.all(target, key => [pk] ) when :many_to_many # OPTIMIZE: cache this result join_model = opts[:join_model].constantize left_key = opts[:left_key] right_key = opts[:right_key] right_values = self.identity_map. all(join_model, left_key => Array(values[primary_key])). collect(&right_key) self.identity_map.all(target, target.primary_key => right_values ) else raise "#{opts[:type]} is not currently supported" end end
identities()
click to toggle source
# File lib/praxis-mapper/sequel_compat.rb, line 86 def identities self.class.identities.each_with_object(Hash.new) do |identity, hash| case identity when Symbol hash[identity] = values[identity].freeze else hash[identity] = values.values_at(*identity).collect(&:freeze) end end end