summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-12-27 10:57:12 -0700
committermo khan <mo@mokhan.ca>2013-12-27 10:57:12 -0700
commit4b6db81e24c4cdb09add78fffd52da5eda7c6e6d (patch)
tree9f7fb710b63b3ab5d8da9aa7aef8ee3234fbe58d
parentda6c34c6e4fe4b4d2ed5fd5cb76fac3b369a5020 (diff)
move identity map to nasty.
-rw-r--r--Gemfile.lock2
-rw-r--r--lib/infrastructure/identity_map.rb21
-rw-r--r--lib/infrastructure/reload_file_strategy.rb4
-rw-r--r--spec/specs/orm/identity_map_spec.rb42
4 files changed, 2 insertions, 67 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index 79fde05..293371a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -28,7 +28,7 @@ GEM
multi_json (1.8.2)
multi_xml (0.5.5)
multipart-post (1.2.0)
- nasty (0.0.1388166636)
+ nasty (0.0.1388166944)
oauth2 (0.9.2)
faraday (~> 0.8)
httpauth (~> 0.2)
diff --git a/lib/infrastructure/identity_map.rb b/lib/infrastructure/identity_map.rb
deleted file mode 100644
index 666665f..0000000
--- a/lib/infrastructure/identity_map.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class IdentityMap
- def initialize(items = {})
- @items = items
- end
-
- def add(item)
- @items[item.id] = item
- end
-
- def has_item_for?(id)
- @items.has_key?(id)
- end
-
- def item_for(id)
- @items[id]
- end
-
- def evict(item)
- @items.reject! { |key, value| key == item.id }
- end
-end
diff --git a/lib/infrastructure/reload_file_strategy.rb b/lib/infrastructure/reload_file_strategy.rb
index 76b297a..29a32f0 100644
--- a/lib/infrastructure/reload_file_strategy.rb
+++ b/lib/infrastructure/reload_file_strategy.rb
@@ -1,7 +1,5 @@
-require 'identity_map'
-
class ReloadFileStrategy
- def initialize(map = IdentityMap.new)
+ def initialize(map = Nasty::IdentityMap.new)
@identity_map = map
end
diff --git a/spec/specs/orm/identity_map_spec.rb b/spec/specs/orm/identity_map_spec.rb
deleted file mode 100644
index 8b8aa74..0000000
--- a/spec/specs/orm/identity_map_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require "spec_helper"
-
-describe IdentityMap do
- let(:sut) { IdentityMap.new }
-
- context "when an item is added" do
- let(:item) { Item.new(:id => 187) }
- before :each do
- sut.add(item)
- end
- it "should indicate that an item with that id is available" do
- sut.has_item_for?(item.id).should be_true
- end
- it "should be able to load the item" do
- sut.item_for(item.id).should == item
- end
- context "when an item is evicted" do
- before :each do
- sut.evict(item)
- end
- it "should indicate that it does not have an item for the evicted id" do
- sut.has_item_for?(item.id).should be_false
- end
- it "should not be able to run the evicted item" do
- sut.item_for(item.id).should be_nil
- end
- end
- end
- context "when no items have been added" do
- it "should indicate that it does not have any items for any id" do
- (0..10).each do |i|
- sut.has_item_for?(i).should be_false
- end
- end
- end
- class Item
- attr_reader :id
- def initialize(attributes)
- @id = attributes[:id]
- end
- end
-end