Skip to content

Commit

Permalink
Use class (instead of class name) as identity map key
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 3, 2012
1 parent c1cb8a2 commit 5e2eff8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def self.lazy_attr_reader(*attrs)
end

def self.new(attrs={})
@@identity_map[self.name] ||= {}
@@identity_map[self.name][Marshal.dump(attrs)] || super(attrs)
@@identity_map[self] ||= {}
@@identity_map[self][Marshal.dump(attrs)] || super(attrs)
end

# Initializes a new object
Expand All @@ -34,7 +34,7 @@ def self.new(attrs={})
# @return [Twitter::Base]
def initialize(attrs={})
self.update(attrs)
@@identity_map[self.class.name][Marshal.dump(attrs)] = self
@@identity_map[self.class][Marshal.dump(attrs)] = self
end

# Fetches an attribute of an object using hash notation
Expand Down
6 changes: 3 additions & 3 deletions lib/twitter/identifiable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Twitter
class Identifiable < Base

def self.new(attrs={})
@@identity_map[self.name] ||= {}
attrs['id'] && @@identity_map[self.name][attrs['id']] ? @@identity_map[self.name][attrs['id']].update(attrs) : super(attrs)
@@identity_map[self] ||= {}
attrs['id'] && @@identity_map[self][attrs['id']] ? @@identity_map[self][attrs['id']].update(attrs) : super(attrs)
end

# Initializes a new object
Expand All @@ -15,7 +15,7 @@ def self.new(attrs={})
def initialize(attrs={})
if attrs['id']
self.update(attrs)
@@identity_map[self.class.name][attrs['id']] = self
@@identity_map[self.class][attrs['id']] = self
else
super
end
Expand Down

0 comments on commit 5e2eff8

Please sign in to comment.