Module: ActiveRecord::QueryMethods

Includes:
Everywhere::Util
Defined in:
lib/everywhere/chain.rb,
lib/everywhere/method.rb,
lib/everywhere/symbol.rb

Instance Method Summary collapse

Instance Method Details

#build_where_with_not_and_like_and_not_like(opts, other = []) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/everywhere/symbol.rb', line 7

def build_where_with_not_and_like_and_not_like(opts, other = [])
  case opts
  when :not
    build_where_without_not_and_like_and_not_like(*other).map {|r| negate r}
  when :like
    build_where_without_not_and_like_and_not_like(*other).map {|r| Arel::Nodes::Matches.new r.left, r.right}
  when :not_like
    build_where_without_not_and_like_and_not_like(*other).map {|r| Arel::Nodes::DoesNotMatch.new r.left, r.right}
  else
    build_where_without_not_and_like_and_not_like(opts, other)
  end
end

#where_like(opts, *rest) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/everywhere/method.rb', line 21

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

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

#where_not(opts, *rest) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/everywhere/method.rb', line 13

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

  relation = clone
  relation.where_values += build_where(opts, rest).map {|r| negate r}
  relation
end

#where_not_like(opts, *rest) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/everywhere/method.rb', line 29

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

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

#where_with_not_and_like_and_not_like(opts = nil, *rest) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/everywhere/chain.rb', line 40

def where_with_not_and_like_and_not_like(opts = nil, *rest)
  if opts.nil?
    spawn.extend(ChainRelation)
  else
    where_without_not_and_like_and_not_like(opts, *rest)
  end
end