Sha256: 9895800727a176a7d088392e5d1f444a7333652e54759c50b11c3a9f1ed7cf46

Contents?: true

Size: 514 Bytes

Versions: 4

Compression:

Stored size: 514 Bytes

Contents

module Casino
  class Query
    attr_accessor :label, :criteria, :conditions

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

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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-casino-0.0.4 lib/casino/query.rb
mongoid-casino-0.0.3 lib/casino/query.rb
mongoid-casino-0.0.2 lib/casino/query.rb
mongoid-casino-0.0.1 lib/casino/query.rb