Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
added associations to identity map
Browse files Browse the repository at this point in the history
  • Loading branch information
pjdavis committed Mar 9, 2010
1 parent 20c07b3 commit ac22721
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/identity_map/active_record/associations.rb
@@ -0,0 +1,31 @@
module IdentityMap

def self.included(base)
base.extend(ClassMethods)
class << base
alias_method_chain :association_instance_set, :identity_map
end
end

module ClassMethods

private

# Set the specified association instance.
def association_instance_set_with_identity_map(name, association)
identity_map = Thread.current['identity_map']
unless identity_map
association_instance_set_without_identity_map("@#{name}", association)
else
association_instance_set_without_identity_map("@#{name}", identity_map.put(association))
end
end


end

end

if Object.const_defined?("ActiveRecord")
ActiveRecord::Associations.send :include, IdentityMap
end

0 comments on commit ac22721

Please sign in to comment.