Skip to content

Commit ba532bf

Browse files
committed
Merge pull request #13 from macreery/read_multi-fix
Properly glob keys as separate arguments to read_multi
2 parents bbe67ce + 69eedb3 commit ba532bf

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.5.1 (Next Release)
2+
--------------------
3+
4+
* Fixed `read_multi` calls so as to enable proper cache reading behavior in stores other than `ActiveSupport::Cache::DalliStore` - [@macreery](http://github.com/macreery)
5+
16
1.5 (04/13/2013)
27
----------------
38

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source "http://rubygems.org"
22

33
gem "activesupport"
4-
gem "mongoid"
4+
gem "mongoid", ">= 3.0.0"
55
gem "hpricot"
66

77
group :development do

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,5 +288,4 @@ Copyright and License
288288

289289
MIT License, see [LICENSE](https://github.com/dblock/mongoid-cached-json/blob/master/LICENSE.md) for details.
290290

291-
(c) 2012 [Art.sy Inc.](http://artsy.github.com) and [Contributors](https://github.com/dblock/mongoid-cached-json/blob/master/HISTORY.md)
292-
291+
(c) 2012 [Art.sy Inc.](http://artsy.github.com) and [Contributors](https://github.com/dblock/mongoid-cached-json/blob/master/CHANGELOG.md)

lib/mongoid-cached-json/cached_json.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def resolve_json_reference(options, object, field, reference_def)
158158
def self.materialize_json_references_with_read_multi(key_refs, partial_json)
159159
unfrozen_keys = key_refs.keys.to_a.map(&:dup) if key_refs # see https://github.com/mperham/dalli/pull/320
160160
read_multi = unfrozen_keys && Mongoid::CachedJson.config.cache.respond_to?(:read_multi)
161-
local_cache = read_multi ? Mongoid::CachedJson.config.cache.read_multi(unfrozen_keys) : {}
161+
local_cache = read_multi ? Mongoid::CachedJson.config.cache.read_multi(*unfrozen_keys) : {}
162162
Mongoid::CachedJson.materialize_json_references(key_refs, local_cache, read_multi) if key_refs
163163
partial_json
164164
end

mongoid-cached-json.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99

1010
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
1111
s.authors = ["Aaron Windsor", "Daniel Doubrovkine", "Frank Macreery"]
12-
s.date = "2013-03-13"
12+
s.date = "2013-05-06"
1313
s.description = "Cached-json is a DSL for describing JSON representations of Mongoid models."
1414
s.email = "[email protected]"
1515
s.extra_rdoc_files = [
@@ -29,15 +29,15 @@ Gem::Specification.new do |s|
2929
s.homepage = "http://github.com/dblock/mongoid-cached-json"
3030
s.licenses = ["MIT"]
3131
s.require_paths = ["lib"]
32-
s.rubygems_version = "1.8.25"
32+
s.rubygems_version = "1.8.24"
3333
s.summary = "Effective model-level JSON caching for the Mongoid ODM."
3434

3535
if s.respond_to? :specification_version then
3636
s.specification_version = 3
3737

3838
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
3939
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
40-
s.add_runtime_dependency(%q<mongoid>, [">= 0"])
40+
s.add_runtime_dependency(%q<mongoid>, [">= 3.0.0"])
4141
s.add_runtime_dependency(%q<hpricot>, [">= 0"])
4242
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
4343
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
4646
s.add_development_dependency(%q<dalli>, ["~> 2.6"])
4747
else
4848
s.add_dependency(%q<activesupport>, [">= 0"])
49-
s.add_dependency(%q<mongoid>, [">= 0"])
49+
s.add_dependency(%q<mongoid>, [">= 3.0.0"])
5050
s.add_dependency(%q<hpricot>, [">= 0"])
5151
s.add_dependency(%q<rspec>, ["~> 2.5"])
5252
s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -56,7 +56,7 @@ Gem::Specification.new do |s|
5656
end
5757
else
5858
s.add_dependency(%q<activesupport>, [">= 0"])
59-
s.add_dependency(%q<mongoid>, [">= 0"])
59+
s.add_dependency(%q<mongoid>, [">= 3.0.0"])
6060
s.add_dependency(%q<hpricot>, [">= 0"])
6161
s.add_dependency(%q<rspec>, ["~> 2.5"])
6262
s.add_dependency(%q<bundler>, ["~> 1.0"])

spec/array_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
it "uses a local cache to fetch repeated objects" do
3636
tool = Tool.create!({ :name => "hammer" })
3737
tool_key = "as_json/unspecified/Tool/#{tool.id}/all/true"
38-
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with([
39-
tool_key
40-
]).and_return({
38+
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(tool_key).and_return({
4139
tool_key => { :x => :y }
4240
})
4341
[ tool, tool, tool ].as_json({ properties: :all }).should == [

spec/dalli_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
tool2 = Tool.create!({ :name => "screwdriver" })
2424
tool2_key = Tool.cached_json_key(options, Tool, tool2.id)
2525
Mongoid::CachedJson.config.cache.should_not_receive(:fetch)
26-
Mongoid::CachedJson.config.cache.should_receive(:read_multi).with([ tool1_key, tool2_key ]).once.and_return({
26+
Mongoid::CachedJson.config.cache.should_receive(:read_multi).with(tool1_key, tool2_key).once.and_return({
2727
tool1_key => { :_id => tool1.id.to_s },
2828
tool2_key => { :_id => tool2.id.to_s }
2929
})

spec/hash_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
it "uses a local cache to fetch repeated objects" do
5050
tool = Tool.create!({ :name => "hammer" })
5151
tool_key = "as_json/unspecified/Tool/#{tool.id}/all/true"
52-
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with([
53-
tool_key
54-
]).and_return({
52+
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(tool_key).and_return({
5553
tool_key => { :x => :y }
5654
})
5755
{

spec/mongoid_criteria_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"as_json/unspecified/ToolBox/#{tool_box.id}/all/false",
4343
"as_json/unspecified/Tool/#{tool2.id}/all/true"
4444
]
45-
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(keys).and_return({
45+
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(*keys).and_return({
4646
keys[0] => { :x => :y },
4747
keys[1] => { :x => :y },
4848
keys[2] => { :x => :y }
@@ -62,7 +62,7 @@
6262
"as_json/unspecified/ToolBox/#{tool_box.id}/all/false",
6363
"as_json/unspecified/Tool/#{tool2.id}/all/true"
6464
]
65-
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(keys).and_return({
65+
Mongoid::CachedJson.config.cache.should_receive(:read_multi).once.with(*keys).and_return({
6666
keys[0] => { :x => :y },
6767
keys[1] => { :x => :y }
6868
})

0 commit comments

Comments
 (0)