Module: Mongoid::Matcher::Size Private
- Defined in:
- lib/mongoid/matcher/size.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
In-memory matcher for $size expression.
Class Method Summary collapse
-
.matches?(exists, value, condition) ⇒ true | false, Boolean
private
Returns whether a value satisfies a $size expression.
Class Method Details
.matches?(exists, value, condition) ⇒ true | false, Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether a value satisfies a $size expression.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mongoid/matcher/size.rb', line 22 module_function def matches?(exists, value, condition) case condition when Float raise Errors::InvalidQuery, "$size argument must be a non-negative integer: #{Errors::InvalidQuery.truncate_expr(condition)}" when Numeric if condition < 0 raise Errors::InvalidQuery, "$size argument must be a non-negative integer: #{Errors::InvalidQuery.truncate_expr(condition)}" end else raise Errors::InvalidQuery, "$size argument must be a non-negative integer: #{Errors::InvalidQuery.truncate_expr(condition)}" end if Array === value value.length == condition else false end end |