hash_conditions 0.1.3 → 0.1.4
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/hash_conditions/core.rb +2 -0
- data/lib/hash_conditions/matcher.rb +10 -5
- data/lib/hash_conditions/version.rb +1 -1
- metadata +3 -3
data/lib/hash_conditions/core.rb
CHANGED
@@ -114,9 +114,11 @@ module HashConditions
|
|
114
114
|
def _ext_parse key, condition, options
|
115
115
|
mod = _ext_get_module key,condition, options
|
116
116
|
parser = mod.replacement
|
117
|
+
op, value = condition.to_a.first
|
117
118
|
|
118
119
|
case parser
|
119
120
|
when String then options[:result].call(extract_expression( parser, condition ), options)
|
121
|
+
when Hash then _ext_read_module( { '$eval' => [ parser, op, value ] }, options )
|
120
122
|
when Proc then _ext_read_module( parser.call( key, condition ), options )
|
121
123
|
end
|
122
124
|
end
|
@@ -40,6 +40,9 @@ module HashConditions
|
|
40
40
|
}
|
41
41
|
|
42
42
|
def self.get_key hash, key
|
43
|
+
__get_values = lambda do | values |
|
44
|
+
values.map{ |x| get_key hash, x }
|
45
|
+
end
|
43
46
|
case key
|
44
47
|
when String, Symbol
|
45
48
|
if key.to_s == '$now'
|
@@ -50,14 +53,16 @@ module HashConditions
|
|
50
53
|
when Hash
|
51
54
|
op, values = key.to_a.first
|
52
55
|
|
53
|
-
values = values.map{ |x| get_key hash, x }
|
54
|
-
|
55
56
|
case op.to_s
|
56
57
|
when *ARITMETIC_OPERATORS.keys
|
57
|
-
values.inject( ARITMETIC_OPERATORS[ op ] )
|
58
|
+
__get_values.call( values ).inject( ARITMETIC_OPERATORS[ op ] )
|
58
59
|
when '$ifNull'
|
59
|
-
|
60
|
-
|
60
|
+
__get_values.call( values ).drop_while{ |n| n.nil? }.shift
|
61
|
+
when '$concat'
|
62
|
+
__get_values.call( values ).join('')
|
63
|
+
when '$concatWithSeparator'
|
64
|
+
separator = values.shift
|
65
|
+
__get_values.call( values ).join( separator )
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_conditions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: 2658515704527149634
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
segments:
|
113
113
|
- 0
|
114
|
-
hash:
|
114
|
+
hash: 2658515704527149634
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
117
|
rubygems_version: 1.8.23
|