Sha256: 36c446f0d263babea6ebe302a575bf9356fb13c94acaec9fb2e2600bd0f69906

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

module ReportsKit
  class ModelConfiguration
    attr_accessor :aggregations, :dimensions, :filters, :autocomplete_scopes

    def initialize
      self.aggregations = []
      self.dimensions = []
      self.filters = []
      self.autocomplete_scopes = []
    end

    def aggregation(key, expression, properties={})
      aggregations << { key: key.to_s, expression: expression }.merge(properties).symbolize_keys
    end

    def dimension(key, properties)
      dimensions << { key: key.to_s }.merge(properties).symbolize_keys
    end

    def filter(key, type_key, properties)
      filters << { key: key.to_s, type_key: type_key }.merge(properties).symbolize_keys
    end

    def autocomplete_scope(*scopes)
      self.autocomplete_scopes += scopes.map(&:to_s)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reports_kit-0.2.0 lib/reports_kit/model_configuration.rb