plucky 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- value.map { |v| Plucky.to_object_id(v) }
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
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Plucky
3
- Version = '0.5.0'
3
+ Version = '0.5.1'
4
4
  end
@@ -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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
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-20 00:00:00 Z
18
+ date: 2012-04-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime