entity_store 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ require 'uri'
4
4
  module EntityStore
5
5
  class MongoEntityStore
6
6
  include Mongo
7
- include Cache
8
7
 
9
8
  def open_connection
10
9
  @db ||= open_store
@@ -74,16 +73,14 @@ module EntityStore
74
73
  if attrs = entities.find_one('_id' => BSON::ObjectId.from_string(id))
75
74
  entity = get_type_constant(attrs['_type']).new(attrs['snapshot'] || {'id' => id, 'version' => attrs['version']})
76
75
 
77
- cache_fetch(id, entity.version) {
78
- since_version = attrs['snapshot'] ? attrs['snapshot']['version'] : nil
76
+ since_version = attrs['snapshot'] ? attrs['snapshot']['version'] : nil
79
77
 
80
- get_events(id, since_version).each do |e|
81
- e.apply(entity)
82
- entity.version = e.entity_version
83
- end
78
+ get_events(id, since_version).each do |e|
79
+ e.apply(entity)
80
+ entity.version = e.entity_version
81
+ end
84
82
 
85
- entity
86
- }
83
+ entity
87
84
  else
88
85
  raise NotFound.new(id) if raise_exception
89
86
  nil
@@ -1,3 +1,3 @@
1
1
  module EntityStore
2
- VERSION = "0.0.9".freeze
2
+ VERSION = "0.0.10".freeze
3
3
  end
data/lib/entity_store.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module EntityStore
2
2
  require 'logger'
3
- require 'entity_store/cache'
4
3
  require 'entity_store/entity'
5
4
  require 'entity_store/entity_value'
6
5
  require 'entity_store/event'
@@ -17,9 +16,6 @@ module EntityStore
17
16
  def setup
18
17
  yield self
19
18
  end
20
-
21
- # Public: cache to be used
22
- attr_accessor :cache
23
19
 
24
20
  def connection_profile
25
21
  @_connection_profile
@@ -29,7 +29,7 @@ describe MongoEntityStore do
29
29
  '_type' => "MongoEntityStoreSpec::DummyEntity",
30
30
  'version' => @version = random_integer
31
31
  }
32
- @entity = MongoEntityStoreSpec::DummyEntity.new(:id => @id, :version => @version)
32
+ @entity = MongoEntityStoreSpec::DummyEntity.new
33
33
  MongoEntityStoreSpec::DummyEntity.stub(:new) { @entity }
34
34
  @entities_collection = mock('MongoCollection', :find_one => @attrs)
35
35
  @store.stub(:entities) { @entities_collection }
@@ -61,10 +61,6 @@ describe MongoEntityStore do
61
61
  subject
62
62
  @entity.version.should eq(@events.last.entity_version)
63
63
  end
64
- it "should attempt to retrieve from the cache" do
65
- @store.should_receive(:cache_fetch).with(@id, @version) { @entity }
66
- subject
67
- end
68
64
  it "should return the entity" do
69
65
  subject.should eq(@entity)
70
66
  end
@@ -84,15 +80,6 @@ describe MongoEntityStore do
84
80
  subject
85
81
  end
86
82
  end
87
- context "when item exists in cache" do
88
- before(:each) do
89
- @another_entity = MongoEntityStoreSpec::DummyEntity.new
90
- @store.stub(:cache_fetch) { @another_entity }
91
- end
92
- it "should reutrn the other entity" do
93
- subject.should eq(@another_entity)
94
- end
95
- end
96
83
  end
97
84
 
98
85
  describe "#get_entity!" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,7 +50,6 @@ extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
52
  - lib/entity_store/attributes.rb
53
- - lib/entity_store/cache.rb
54
53
  - lib/entity_store/config.rb
55
54
  - lib/entity_store/entity.rb
56
55
  - lib/entity_store/entity_value.rb
@@ -1,15 +0,0 @@
1
- # Private: wrapper for the assigned cache
2
- #
3
- module EntityStore
4
- module Cache
5
-
6
- def cache_enabled?
7
- EntityStore.cache
8
- end
9
-
10
- def cache_fetch(id, version)
11
- cache_enabled? ? EntityStore.cache.fetch("_entity_store_#{id}_#{version}") { yield } : yield
12
- end
13
- end
14
-
15
- end