Module: Sequel::FilterHaving

Defined in:
lib/sequel/extensions/filter_having.rb

Instance Method Summary collapse

Instance Method Details

#and(*cond, &block) ⇒ Object

Operate on HAVING clause if HAVING clause already present.



25
26
27
28
29
30
31
# File 'lib/sequel/extensions/filter_having.rb', line 25

def and(*cond, &block)
  if @opts[:having]
    having(*cond, &block)
  else
    super
  end
end

#exclude(*cond, &block) ⇒ Object

Operate on HAVING clause if HAVING clause already present.



34
35
36
37
38
39
40
# File 'lib/sequel/extensions/filter_having.rb', line 34

def exclude(*cond, &block)
  if @opts[:having]
    exclude_having(*cond, &block)
  else
    super
  end
end

#filter(*cond, &block) ⇒ Object

Operate on HAVING clause if HAVING clause already present.



43
44
45
46
47
48
49
# File 'lib/sequel/extensions/filter_having.rb', line 43

def filter(*cond, &block)
  if @opts[:having]
    having(*cond, &block)
  else
    super
  end
end

#or(*cond, &block) ⇒ Object

Operate on HAVING clause if HAVING clause already present.



52
53
54
55
56
57
58
59
# File 'lib/sequel/extensions/filter_having.rb', line 52

def or(*cond, &block)
  if having = @opts[:having]
    cond = cond.first if cond.size == 1
    clone(:having => SQL::BooleanExpression.new(:OR, having, filter_expr(cond, &block)))
  else
    super
  end
end