Class: Druid::Having
- Inherits:
-
Object
- Object
- Druid::Having
- Includes:
- ActiveModel::Model
- Defined in:
- lib/druid/having.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AggregationValidator, HavingValidator, HavingsValidator
Instance Attribute Summary collapse
-
#aggregation ⇒ Object
Returns the value of attribute aggregation.
-
#havingSpec ⇒ Object
Returns the value of attribute havingSpec.
-
#havingSpecs ⇒ Object
Returns the value of attribute havingSpecs.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #chain(other) ⇒ Object
- #clause? ⇒ Boolean
- #method_missing(name, *args) ⇒ Object
- #operator? ⇒ Boolean
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
#aggregation ⇒ Object
Returns the value of attribute aggregation.
56 57 58 |
# File 'lib/druid/having.rb', line 56 def aggregation @aggregation end |
#havingSpec ⇒ Object
Returns the value of attribute havingSpec.
42 43 44 |
# File 'lib/druid/having.rb', line 42 def havingSpec @havingSpec end |
#havingSpecs ⇒ Object
Returns the value of attribute havingSpecs.
24 25 26 |
# File 'lib/druid/having.rb', line 24 def havingSpecs @havingSpecs end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/druid/having.rb', line 5 def type @type end |
#value ⇒ Object
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( = {}) super(.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
67 68 69 |
# File 'lib/druid/having.rb', line 67 def clause? is_a?(HavingClause) end |
#operator? ⇒ Boolean
71 72 73 |
# File 'lib/druid/having.rb', line 71 def operator? is_a?(HavingOperator) end |