Sha256: 36f2e6a677cb8420d5ad5260a851f20257811c328d610166ec0db153a06126f5

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module ActiveOLAP
  
  class Configurator
    
    # initializes a OLAP::Configurator object, which is used in the block 
    # passed to the call enable_active_olap. It can be used to register
    # dimensions and classes
    def initialize(klass)
      @klass = klass
    end
    
    # registers a dimension for the class it belongs to
    def dimension(name, definition = nil)
      definition = name.to_sym if definition.nil?
      @klass.active_olap_dimensions[name] = definition
    end
    
    def time_dimension(name, field, defaults = {})
      @klass.active_olap_dimensions[name] = Proc.new do |*options|
        options = options.empty? ? {} : options.first
        { :trend => defaults.merge(options).merge(:timestamp_field => field) }
      end
    end
    
    # registers an aggregate for the class it belongs to
    def aggregate(name, definition = nil, options = {})
      definition = name if definition.nil?
      agg_definition = options.merge(:expression => definition)
      @klass.active_olap_aggregates[name] = agg_definition
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
wvanbergen-active_olap-0.0.2 lib/active_olap/configurator.rb
active_olap-0.0.5 lib/active_olap/configurator.rb
active_olap-0.0.4 lib/active_olap/configurator.rb
active_olap-0.0.3 lib/active_olap/configurator.rb
active_olap-0.0.2 lib/active_olap/configurator.rb