Sha256: 6b7675d560e9d9b36bd52b5eee919d0fec83005a159713589c42a8e587de8e63

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

module Prosperity
  class Metric 
    def self.scope(&block)
      if block_given?
        @scope = block.call
      else
        raise MissingScope.new if @scope.nil?
        @scope
      end
    end

    def self.options(name = nil, &block)
      @options ||= default_options
      if block_given?
        @options[name] = Metrics::Option.new(name, &block)
      else
        raise MissingScope.new if @options.nil?
        @options
      end
    end

    def extractors
      [Extractors::Group, Extractors::Count]
    end

    def group_by
      :created_at
    end

    def scope
      self.class.scope
    end

    def options
      self.class.options
    end

    private

    def self.default_options
      o = Metrics::Option.new("default") do |scope|
        scope
      end
      {"default" => o}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prosperity-0.0.1 lib/prosperity/metric.rb