plucky 0.5.0 → 0.5.1
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.
- data/lib/plucky/criteria_hash.rb +4 -3
- data/lib/plucky/version.rb +1 -1
- data/test/plucky/test_criteria_hash.rb +4 -0
- metadata +4 -4
data/lib/plucky/criteria_hash.rb
CHANGED
@@ -121,13 +121,14 @@ module Plucky
|
|
121
121
|
def normalized_value(parent_key, key, value)
|
122
122
|
case value
|
123
123
|
when Array, Set
|
124
|
-
if object_id?(parent_key)
|
125
|
-
|
126
|
-
elsif NestingOperators.include?(key)
|
124
|
+
value = value.map { |v| Plucky.to_object_id(v) } if object_id?(parent_key)
|
125
|
+
if NestingOperators.include?(key)
|
127
126
|
value.map { |v| CriteriaHash.new(v, options).to_hash }
|
128
127
|
elsif parent_key == key
|
128
|
+
# we're not nested and not the value for a symbol operator
|
129
129
|
{'$in' => value.to_a}
|
130
130
|
else
|
131
|
+
# we are a value for a symbol operator or nested hash
|
131
132
|
value.to_a
|
132
133
|
end
|
133
134
|
when Time
|
data/lib/plucky/version.rb
CHANGED
@@ -208,6 +208,10 @@ class CriteriaHashTest < Test::Unit::TestCase
|
|
208
208
|
should "not turn value to $in with $nor key" do
|
209
209
|
CriteriaHash.new(:$nor => [{:numbers => 1}, {:numbers => 2}] )[:$nor].should == [{:numbers=>1}, {:numbers=>2}]
|
210
210
|
end
|
211
|
+
|
212
|
+
should "default to $in even with ObjectId keys" do
|
213
|
+
CriteriaHash.new({:mistake_id => [1,2,3]}, :object_ids => [:mistake_id])[:mistake_id].should == {'$in' => [1,2,3]}
|
214
|
+
end
|
211
215
|
end
|
212
216
|
|
213
217
|
context "with set value" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plucky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
18
|
+
date: 2012-04-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|