Sha256: df94daf9bd98fd49ce652cd1afa0a391aa6a1635d3aa866491303ed1ca117c73

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require 'abaci/version'

module Abaci
  autoload :Counter,      'abaci/counter'
  autoload :DateRange,    'abaci/date_range'
  autoload :Metric,       'abaci/metric'
  autoload :Store,        'abaci/store'

  # Configuration options
  class << self
    def [](key)
      Counter[key]
    end

    # Gets all specific metrics stored, without date-specific keys
    def metrics
      Metric.all
    end

    def options
      @options ||= {
        :redis => nil,
        :prefix => 'ab'
      }
    end

    def prefix=(value)
      @store = nil
      options[:prefix] = value
    end

    def prefix
      options[:prefix]
    end

    def redis=(value)
      @store = nil
      options[:redis] = value
    end

    def store
      @store ||= Store.new(options)
    end
    alias_method :redis, :store

    def summary
      Counter.all
    end

    def method_missing(method, *args)
      Counter.send(method, *args)
    end
  end

  # Alias Stat to Abaci::Counter if nothing else is using the Stat namespace
  unless defined?(::Stat)
    ::Stat = Counter
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abaci-0.2.0 lib/abaci.rb