@@ -37,7 +37,7 @@ def add_field_expression(field, value)
3737 raise ArgumentError , "Field must be a string: #{ field } "
3838 end
3939
40- if field [ 0 ] == ?$
40+ if field . start_with? ( '$' )
4141 raise ArgumentError , "Field cannot be an operator (i.e. begin with $): #{ field } "
4242 end
4343
@@ -47,7 +47,7 @@ def add_field_expression(field, value)
4747 if value . is_a? ( Hash ) && selector [ field ] . is_a? ( Hash ) &&
4848 value . keys . all? { |key |
4949 key_s = key . to_s
50- key_s [ 0 ] == ?$ && !selector [ field ] . key? ( key_s )
50+ key_s . start_with? ( '$' ) && !selector [ field ] . key? ( key_s )
5151 }
5252 then
5353 # Multiple operators can be combined on the same field by
@@ -184,7 +184,7 @@ def add_operator_expression(operator, op_expr)
184184 raise ArgumentError , "Operator must be a string: #{ operator } "
185185 end
186186
187- unless operator [ 0 ] == ?$
187+ unless operator . start_with? ( '$' )
188188 raise ArgumentError , "Operator must begin with $: #{ operator } "
189189 end
190190
@@ -219,7 +219,7 @@ def add_one_expression(field, value)
219219 raise ArgumentError , "Field must be a string: #{ field } "
220220 end
221221
222- if field [ 0 ] == ?$
222+ if field . start_with? ( '$' )
223223 add_operator_expression ( field , value )
224224 else
225225 add_field_expression ( field , value )
0 commit comments