Module: Scopes::Like::QueryMethods

Defined in:
lib/scopes/like.rb

Instance Method Summary collapse

Instance Method Details

#like(opts, *rest) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/scopes/like.rb', line 8

def like(opts, *rest)
  return self if opts.blank?

  relation = clone
  relation.where_values += build_where(opts, rest).map { |relation| Arel::Nodes::Matches.new relation.left, relation.right }
  relation
end

#not_like(opts, *rest) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/scopes/like.rb', line 16

def not_like(opts, *rest)
  return self if opts.blank?

  relation = clone
  relation.where_values += build_where(opts, rest).map { |relation| Arel::Nodes::DoesNotMatch.new relation.left, relation.right }
  relation
end