Skip to content

Commit

Permalink
Move IdentityMapKeyError under Twitter::Error namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jul 28, 2012
1 parent 4d5a5c3 commit f1491d2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/twitter/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'twitter/core_ext/kernel'
require 'twitter/error/identity_map_key_error'

module Twitter
class Base
Expand Down Expand Up @@ -39,7 +40,7 @@ def self.fetch(attrs)
return object
end
return yield if block_given?
raise Twitter::IdentityMapKeyError, 'key not found'
raise Twitter::Error::IdentityMapKeyError, "key not found"
end

# Stores an object in the identity map.
Expand Down
9 changes: 9 additions & 0 deletions lib/twitter/error/identity_map_key_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'twitter/error'

module Twitter
class Error
# Inherit from KeyError when Ruby 1.8 compatibility is removed
class IdentityMapKeyError < ::IndexError
end
end
end
3 changes: 2 additions & 1 deletion lib/twitter/identity.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'twitter/base'
require 'twitter/error/identity_map_key_error'

module Twitter
class Identity < Twitter::Base
Expand All @@ -12,7 +13,7 @@ def self.fetch(attrs)
end

return yield if block_given?
raise Twitter::IdentityMapKeyError, 'key not found'
raise Twitter::Error::IdentityMapKeyError, "key not found"
end

# Stores an object in the identity map.
Expand Down
4 changes: 0 additions & 4 deletions lib/twitter/identity_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ def store(id, object)

end

# Inherit from KeyError when Ruby 1.8 compatibility is removed
class IdentityMapKeyError < ::IndexError
end

end
2 changes: 1 addition & 1 deletion spec/twitter/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
it "raises an error on objects that don't exist" do
lambda {
Twitter::Base.fetch(:id => 6)
}.should raise_error(Twitter::IdentityMapKeyError)
}.should raise_error(Twitter::Error::IdentityMapKeyError)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/identifiable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
it "raises an error on objects that don't exist" do
lambda {
Twitter::Identity.fetch(:id => 6)
}.should raise_error(Twitter::IdentityMapKeyError)
}.should raise_error(Twitter::Error::IdentityMapKeyError)
end
end

Expand Down

0 comments on commit f1491d2

Please sign in to comment.