origin 1.0.8 → 1.0.9

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.
@@ -6,6 +6,12 @@
6
6
 
7
7
  ### Resolved Issues
8
8
 
9
+ ## 1.0.9
10
+
11
+ ### Resolved Issues
12
+
13
+ * \#45 Fixed $not query negation with regular expressions. (Andrew Bennett)
14
+
9
15
  ## 1.0.8
10
16
 
11
17
  ### Resolved Issues
@@ -59,7 +59,7 @@ module Origin
59
59
  #
60
60
  # @since 1.0.0
61
61
  def specify(value, negating = false)
62
- { self => value }
62
+ (negating && value.regexp?) ? { self => { "$not" => value } } : { self => value }
63
63
  end
64
64
 
65
65
  # Get the string as a sort direction.
@@ -17,7 +17,7 @@ module Origin
17
17
  #
18
18
  # @since 1.0.0
19
19
  def specify(value, negating = false)
20
- { self => value }
20
+ (negating && value.regexp?) ? { self => { "$not" => value } } : { self => value }
21
21
  end
22
22
 
23
23
  # Get the symbol as a sort direction.
@@ -57,7 +57,7 @@ module Origin
57
57
  def specify(object, negating = false)
58
58
  value = block ? block[object] : object
59
59
  expression = { operator => expanded ? { expanded => value } : value }
60
- { name.to_s => negating ? { "$not" => expression } : expression }
60
+ { name.to_s => (negating && operator != "$not") ? { "$not" => expression } : expression }
61
61
  end
62
62
 
63
63
  # Get the key as raw Mongo sorting options.
@@ -352,12 +352,21 @@ module Origin
352
352
  # @example Negate the selection.
353
353
  # selectable.not.in(field: [ 1, 2 ])
354
354
  #
355
+ # @example Add the $not criterion.
356
+ # selectable.not(name: /Bob/)
357
+ #
358
+ # @example Execute a $not in a where query.
359
+ # selectable.where(:field.not => /Bob/)
360
+ #
361
+ # @param [ Hash ] criterion The field/value pairs to negate.
362
+ #
355
363
  # @return [ Selectable ] The negated selectable.
356
364
  #
357
365
  # @since 1.0.0
358
- def not
359
- tap { |query| query.negating = true }
366
+ def not(*criterion)
367
+ (criterion.size == 0) ? tap { |query| query.negating = true } : __override__(criterion.first, "$not")
360
368
  end
369
+ key :not, :override, "$not"
361
370
 
362
371
  # Adds $or selection to the selectable.
363
372
  #
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Origin
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-01 00:00:00.000000000 Z
12
+ date: 2012-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: 2365278983119177575
148
+ hash: 1767126872631308027
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements: