mongory 0.8.0 → 0.8.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.
- checksums.yaml +4 -4
- data/docs/advanced_usage.md +10 -0
- data/lib/mongory/c_matcher.rb +7 -7
- data/lib/mongory/query_builder.rb +6 -0
- data/lib/mongory/version.rb +1 -1
- data/lib/mongory.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea774db3304817acd068531393945fc6c812ac00c8d0b47e71f6740bc8792f67
|
4
|
+
data.tar.gz: c331c32c9b464249b1e24cac91c2f60bba87065dfe2f48bc5a44faad4bc504b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49764016c348ef886f1e05a0303cb139d793340b20790ef6d8b39328cc8b5621f097ecff587e76b62157d8b6dadf26ef6ab57d6bca6d9dccf9c3e1643e914045
|
7
|
+
data.tar.gz: 2e5b5067ee8df7d94778c5e47dc2bd0e3fc8c17e31e958d16b50a8c21d0821cd65f360c42116b30d05d58251e1e30cbba58c1482a5aabb915fec94c8e4a6abea
|
data/docs/advanced_usage.md
CHANGED
@@ -25,6 +25,16 @@ users.mongory
|
|
25
25
|
posts.mongory
|
26
26
|
.where(:tags.elem_match => { :name => 'ruby', :priority.gt => 5 })
|
27
27
|
.where(:comments.every => { :approved => true })
|
28
|
+
|
29
|
+
# Since Matcher provide `to_proc` method, you could treat Matcher as a block
|
30
|
+
matcher = Mongory::QueryMatcher.new({
|
31
|
+
:tags.elem_match => { :name => 'ruby', :priority.gt => 5 },
|
32
|
+
:comments.every => { :approved => true }
|
33
|
+
})
|
34
|
+
|
35
|
+
# Will filter
|
36
|
+
posts_1.select!(&matcher)
|
37
|
+
posts_2.select!(&matcher)
|
28
38
|
```
|
29
39
|
|
30
40
|
## Integration with ActiveRecord
|
data/lib/mongory/c_matcher.rb
CHANGED
@@ -10,9 +10,13 @@ module Mongory
|
|
10
10
|
# collection.mongory.c.where(condition).to_a
|
11
11
|
class CMatcher
|
12
12
|
# @!method self.new(condition)
|
13
|
-
# @param condition [
|
13
|
+
# @param condition [Hash] the condition
|
14
14
|
# @return [Mongory::CMatcher] a new matcher
|
15
15
|
# @note This method is implemented in the C extension
|
16
|
+
# @!method self.trace_result_colorful=(colorful)
|
17
|
+
# @param colorful [Boolean] whether to enable colorful trace result
|
18
|
+
# @return [void]
|
19
|
+
# @note This method is implemented in the C extension
|
16
20
|
#
|
17
21
|
# @!method match?(record)
|
18
22
|
# @param record [Object] the record to match against
|
@@ -20,7 +24,7 @@ module Mongory
|
|
20
24
|
# @note This method is implemented in the C extension
|
21
25
|
# @!method explain
|
22
26
|
# @return [void]
|
23
|
-
# @note This method will print
|
27
|
+
# @note This method will print matcher tree structure
|
24
28
|
# @note This method is implemented in the C extension
|
25
29
|
# @!method trace
|
26
30
|
# @return [Boolean] true if the record matches the condition, false otherwise
|
@@ -39,15 +43,11 @@ module Mongory
|
|
39
43
|
# @note This method will print trace result
|
40
44
|
# @note This method is implemented in the C extension
|
41
45
|
# @!method condition
|
42
|
-
# @return [
|
46
|
+
# @return [Hash] the condition
|
43
47
|
# @note This method is implemented in the C extension
|
44
48
|
# @!method context
|
45
49
|
# @return [Utils::Context] the context
|
46
50
|
# @note This method is implemented in the C extension
|
47
|
-
# @!method trace_result_colorful=
|
48
|
-
# @param colorful [Boolean] whether to enable colorful trace result
|
49
|
-
# @return [Boolean]
|
50
|
-
# @note This method is implemented in the C extension
|
51
51
|
|
52
52
|
# @return [Proc] a Proc that performs the matching operation
|
53
53
|
def to_proc
|
@@ -55,10 +55,16 @@ module Mongory
|
|
55
55
|
# Iterates through all records that match the current matcher.
|
56
56
|
# Uses a compiled Proc for faster matching.
|
57
57
|
#
|
58
|
+
# @deprecated
|
59
|
+
# Since C extension has implemented, the fast mode is no longer needed. Use C extension instead.
|
60
|
+
#
|
61
|
+
# This method is deprecated and will be removed in future versions.
|
62
|
+
#
|
58
63
|
# @yieldparam record [Object] each matching record
|
59
64
|
# @return [Enumerator] if no block given
|
60
65
|
# @return [void] if block given
|
61
66
|
def fast
|
67
|
+
warn('Deprecated: Since C extension has implemented, the fast mode is no longer needed. Use C extension instead.')
|
62
68
|
return to_enum(:fast) unless block_given?
|
63
69
|
|
64
70
|
@context.need_convert = false
|
data/lib/mongory/version.rb
CHANGED
data/lib/mongory.rb
CHANGED
@@ -118,7 +118,7 @@ end
|
|
118
118
|
|
119
119
|
begin
|
120
120
|
abi = RUBY_VERSION.split('.').first(2).join('.')
|
121
|
-
|
121
|
+
require_relative "core/#{abi}/mongory_ext"
|
122
122
|
require_relative 'mongory/c_query_builder'
|
123
123
|
require_relative 'mongory/c_matcher'
|
124
124
|
rescue LoadError => e
|