From f1491d2fe1827140ea42b2618d0a25dc03110394 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Fri, 27 Jul 2012 16:18:11 -0700 Subject: [PATCH] Move IdentityMapKeyError under Twitter::Error namespace --- lib/twitter/base.rb | 3 ++- lib/twitter/error/identity_map_key_error.rb | 9 +++++++++ lib/twitter/identity.rb | 3 ++- lib/twitter/identity_map.rb | 4 ---- spec/twitter/base_spec.rb | 2 +- spec/twitter/identifiable_spec.rb | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 lib/twitter/error/identity_map_key_error.rb diff --git a/lib/twitter/base.rb b/lib/twitter/base.rb index 7589f3a32..8ec0102b1 100644 --- a/lib/twitter/base.rb +++ b/lib/twitter/base.rb @@ -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. diff --git a/lib/twitter/error/identity_map_key_error.rb b/lib/twitter/error/identity_map_key_error.rb new file mode 100644 index 000000000..1064d9466 --- /dev/null +++ b/lib/twitter/error/identity_map_key_error.rb @@ -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 diff --git a/lib/twitter/identity.rb b/lib/twitter/identity.rb index 6305a4ae7..ae6f4930f 100644 --- a/lib/twitter/identity.rb +++ b/lib/twitter/identity.rb @@ -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. diff --git a/lib/twitter/identity_map.rb b/lib/twitter/identity_map.rb index ac5b10ad3..fd18fa760 100644 --- a/lib/twitter/identity_map.rb +++ b/lib/twitter/identity_map.rb @@ -19,8 +19,4 @@ def store(id, object) end - # Inherit from KeyError when Ruby 1.8 compatibility is removed - class IdentityMapKeyError < ::IndexError - end - end diff --git a/spec/twitter/base_spec.rb b/spec/twitter/base_spec.rb index 68079d5fe..b5f6a2f33 100644 --- a/spec/twitter/base_spec.rb +++ b/spec/twitter/base_spec.rb @@ -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 diff --git a/spec/twitter/identifiable_spec.rb b/spec/twitter/identifiable_spec.rb index 90da4feee..1d47b14c7 100644 --- a/spec/twitter/identifiable_spec.rb +++ b/spec/twitter/identifiable_spec.rb @@ -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