Class: Casino::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/casino/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, conditions, *criteria) ⇒ Query

Returns a new instance of Query.



5
6
7
8
9
# File 'lib/casino/query.rb', line 5

def initialize(label, conditions, *criteria)
  self.label = label
  self.conditions = conditions
  self.criteria = criteria
end

Instance Attribute Details

#conditionsObject

Returns the value of attribute conditions.



3
4
5
# File 'lib/casino/query.rb', line 3

def conditions
  @conditions
end

#criteriaObject

Returns the value of attribute criteria.



3
4
5
# File 'lib/casino/query.rb', line 3

def criteria
  @criteria
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/casino/query.rb', line 3

def label
  @label
end

Instance Method Details

#build_conditions(dimension) ⇒ Object



15
16
17
18
19
20
# File 'lib/casino/query.rb', line 15

def build_conditions(dimension)
  criteria.map do |condition|
    [ dimension.approach[:operator],
      { dimension.field => condition } ]
  end
end

#merge(dimension) ⇒ Object



11
12
13
# File 'lib/casino/query.rb', line 11

def merge(dimension)
  self.class.new(label, build_conditions(dimension), *criteria)
end