模块:Mongoid::Matcher::Regex Private
- 定义于:
- lib/mongoid/matcher/regex.rb
Overview
该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。
$regex 表达式的内存中匹配器。
类方法摘要折叠
-
。匹配? (exists、value、condition)→ true | false,布尔值
private
返回一个值是否满足 $regex表达式。
-
。 matches_array_or_scalar? (值,条件)→ true | false,布尔值
private
返回标量或大量值是否与正则表达式匹配。
类方法详细信息
。匹配? (exists, value, Condition) ⇒ true | false ,布尔值
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回一个值是否满足 $regex表达式。
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mongoid/matcher/regex.rb', line 21 module_function def 匹配?(存在, 值, 条件) 条件 = 案例 条件 when regexp 条件 when BSON::regexp::原始 条件.编译 else # 请注意,字符串必须已转换为正则表达式 # 已实例(如果提供,则考虑 $options)。 提高 Errors::InvalidQuery, " $regex 需要正则表达式参数: #{ Errors :: InvalidQuery . truncate_expr ( condition ) } " end 案例 值 when 阵列 值.任何? do |v| v =~ 条件 end when 字符串 值 =~ 条件 else false end end |
。 matches_array_or_scalar? (值,条件)→ true | false ,布尔值
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回标量或大量值是否与正则表达式匹配。
54 55 56 57 58 59 60 61 62 |
# File 'lib/mongoid/matcher/regex.rb', line 54 module_function def matches_array_or_scalar?(值, 条件) if 阵列 === 值 值.任何? do |v| 匹配?(true, v, 条件) end else 匹配?(true, 值, 条件) end end |