Class: ActiveRecord::Refined::AST::Match
- Defined in:
- lib/active_record/refined/ast.rb
Overview
Regular expression match: REGEXP on MySQL, ~ on PostgreSQL. SQLite has no regexp operator built in, so Arel raises NotImplementedError there.
Instance Attribute Summary collapse
-
#negated ⇒ Object
readonly
Returns the value of attribute negated.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(operand, pattern, negated: false) ⇒ Match
constructor
A new instance of Match.
- #to_arel(table) ⇒ Object
Methods inherited from Predicate
Methods inherited from Node
Constructor Details
#initialize(operand, pattern, negated: false) ⇒ Match
Returns a new instance of Match.
266 267 268 269 270 |
# File 'lib/active_record/refined/ast.rb', line 266 def initialize(operand, pattern, negated: false) @operand = operand @pattern = pattern.is_a?(Regexp) ? regexp_source(pattern) : pattern @negated = negated end |
Instance Attribute Details
#negated ⇒ Object (readonly)
Returns the value of attribute negated.
264 265 266 |
# File 'lib/active_record/refined/ast.rb', line 264 def negated @negated end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
264 265 266 |
# File 'lib/active_record/refined/ast.rb', line 264 def operand @operand end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
264 265 266 |
# File 'lib/active_record/refined/ast.rb', line 264 def pattern @pattern end |
Instance Method Details
#to_arel(table) ⇒ Object
272 273 274 275 276 277 278 279 |
# File 'lib/active_record/refined/ast.rb', line 272 def to_arel(table) arel_operand = to_arel_operand(operand, table) if negated arel_operand.does_not_match_regexp(pattern) else arel_operand.matches_regexp(pattern) end end |