模块:Mongoid::Matcher::Type Private
- 定义于:
- lib/mongoid/matcher/type.rb
Overview
该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。
$type 表达式的内存中匹配器。
类方法摘要折叠
-
。匹配? (exists、value、condition)→ true | false,布尔值
private
返回一个值是否满足 $type表达式。
-
。 one_matches? (exists、value、condition)→ true | false,布尔值
private
返回一个值是否满足单个 $type表达式值。
类方法详细信息
。匹配? (exists, value, Condition) ⇒ true | false ,布尔值
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回一个值是否满足 $type表达式。
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mongoid/matcher/type.rb', line 22 module_function def 匹配?(存在, 值, 条件) 条件 = 案例 条件 when 阵列 条件 when 整型 [条件] else 提高 Errors::InvalidQuery, "未知的 $type 参数: #{ condition } " end 条件.每 do |条件| if one_matches?(存在, 值, 条件) return true end end false end |
。 one_matches? (exists, value, Condition) ⇒ true | false ,布尔值
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回一个值是否满足单个 $type表达式值。
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/mongoid/matcher/type.rb', line 50 module_function def one_matches?(存在, 值, 条件) 案例 条件 when 1 # Double Float === 值 when 2 # string 字符串 === 值 when 3 # 对象 哈希 === 值 when 4 # 数组 阵列 === 值 when 5 # 二进制数据 BSON::二进制文件 === 值 when 6 # Undefined BSON::未定义 === 值 when 7 # ObjectId BSON::ObjectId === 值 when 8 # 布尔值 TrueClass === 值 || FalseClass === 值 when 9 # 日期 Date === 值 || 时间 === 值 || 日期时间 === 值 when 10 # Null 存在 && NilClass === 值 when 11 # 正则表达式 regexp::原始 === 值 || ::regexp === 值 when 12 # DBPointer 已弃用 BSON::数据库指针 === 值 when 13 # JavaScript BSON::代码 === 值 when 14 # 符号已弃用 符号 === 值 || BSON::符号::原始 === 值 when 15 # 含已弃用代码的JavaScript BSON::CodeWithScope === 值 when 16 # 32位整型 BSON::Int32 === 值 || 整型 === 值 && (-2**32..2**32-1).包括?(值) when 17 # 时间戳 BSON::时间戳 === 值 when 18 # Long BSON::Int64 === 值 || 整型 === 值 && (-2**64..2**64-1).包括?(值) && !(-2**32..2**32-1).包括?(值) when 19 # Decimal BSON::Decimal128 === 值 when -1 # minKey BSON::最小键值 === 值 when 127 # maxKey BSON::Max key === 值 else 提高 Errors::InvalidQuery, "未知的 $type 参数: #{ condition } " end end |