mongoid_query_string_interface 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mongoid_query_string_interface.rb +19 -2
- data/lib/version.rb +1 -1
- metadata +4 -4
@@ -95,7 +95,12 @@ module Mongoid
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def parse_value(value, operator)
|
98
|
-
parse_date(value) or
|
98
|
+
parse_date(value) or
|
99
|
+
parse_integer(value) or
|
100
|
+
parse_float(value) or
|
101
|
+
parse_array(value, operator) or
|
102
|
+
parse_regex(value) or
|
103
|
+
parse_boolean_and_nil(value)
|
99
104
|
end
|
100
105
|
|
101
106
|
def parse_date(date)
|
@@ -103,7 +108,7 @@ module Mongoid
|
|
103
108
|
rescue Exception
|
104
109
|
nil
|
105
110
|
end
|
106
|
-
|
111
|
+
|
107
112
|
def parse_integer(integer)
|
108
113
|
if match = integer.match(/^\d+$/)
|
109
114
|
match[0].to_i
|
@@ -128,6 +133,18 @@ module Mongoid
|
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
136
|
+
def parse_boolean_and_nil(value)
|
137
|
+
unless value.nil? || value.empty?
|
138
|
+
if ['true', 'false'].include?(value.strip)
|
139
|
+
value.strip == 'true'
|
140
|
+
elsif value.strip == 'nil'
|
141
|
+
nil
|
142
|
+
else
|
143
|
+
value
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
131
148
|
def array_operator?(operator)
|
132
149
|
ARRAY_CONDITIONAL_OPERATORS.map { |op| "$#{op}" }.include?(operator.to_s)
|
133
150
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_query_string_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vicente Mundim
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-10 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|