Class: Druid::Having

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/druid/having.rb

Direct Known Subclasses

HavingClause, HavingOperator

Defined Under Namespace

Classes: AggregationValidator, HavingValidator, HavingsValidator

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



61
62
63
64
65
# File 'lib/druid/having.rb', line 61

def method_missing(name, *args)
  if args.empty?
    HavingClause.new(aggregation: name)
  end
end

Instance Attribute Details

#aggregationObject

Returns the value of attribute aggregation.



56
57
58
# File 'lib/druid/having.rb', line 56

def aggregation
  @aggregation
end

#havingSpecObject

Returns the value of attribute havingSpec.



42
43
44
# File 'lib/druid/having.rb', line 42

def havingSpec
  @havingSpec
end

#havingSpecsObject

Returns the value of attribute havingSpecs.



24
25
26
# File 'lib/druid/having.rb', line 24

def havingSpecs
  @havingSpecs
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/druid/having.rb', line 5

def type
  @type
end

#valueObject

Returns the value of attribute value.



59
60
61
# File 'lib/druid/having.rb', line 59

def value
  @value
end

Instance Method Details

#as_json(options = {}) ⇒ Object



87
88
89
# File 'lib/druid/having.rb', line 87

def as_json(options = {})
  super(options.merge(except: %w(errors validation_context)))
end

#chain(other) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/druid/having.rb', line 75

def chain(other)
  return unless other
  if self.operator? && self.and?
    having = self
  else
    having = HavingOperator.new(type: 'and')
    having.havingSpecs << self
  end
  having.havingSpecs << other
  having
end

#clause?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/druid/having.rb', line 67

def clause?
  is_a?(HavingClause)
end

#operator?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/druid/having.rb', line 71

def operator?
  is_a?(HavingOperator)
end