Permalink
Browse files

Move IdentityMapKeyError under Twitter::Error namespace

  • Loading branch information...
1 parent 4d5a5c3 commit f1491d2fe1827140ea42b2618d0a25dc03110394 @sferik committed Jul 27, 2012
View
@@ -1,4 +1,5 @@
require 'twitter/core_ext/kernel'
+require 'twitter/error/identity_map_key_error'
module Twitter
class Base
@@ -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.
@@ -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
View
@@ -1,4 +1,5 @@
require 'twitter/base'
+require 'twitter/error/identity_map_key_error'
module Twitter
class Identity < Twitter::Base
@@ -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.
@@ -19,8 +19,4 @@ def store(id, object)
end
- # Inherit from KeyError when Ruby 1.8 compatibility is removed
- class IdentityMapKeyError < ::IndexError
- end
-
end
@@ -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
@@ -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

0 comments on commit f1491d2

Please sign in to comment.