Sha256: 28fd7262e1ea520ddb4edb9b47bceeb426e155133ea2338a9e604076311caf27

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

require 'singleton'

module MeterCat

  class Config
    include Singleton

    NIL_PROC = proc {}

    attr_accessor :calculator, :expiration, :retry_attempts, :retry_delay
    attr_accessor :from, :mail_days, :mail_names, :subject, :to
    attr_accessor :layout

    def initialize
      @calculator = MeterCat::Calculator.new
      @expiration = Meter::DEFAULT_EXPIRATION
      @retry_attempts = Meter::DEFAULT_RETRY_ATTEMPTS
      @retry_delay = Meter::DEFAULT_RETRY_DELAY
    end

    def ratio(name, numerator, denominator)
      @calculator.ratio(name, numerator, denominator)
    end

    def percentage(name, numerator, denominator)
      @calculator.percentage(name, numerator, denominator)
    end

    def sum(name, values)
      @calculator.sum(name, values)
    end

    def authenticate_with(&blk)
      @authenticate = blk if blk
      @authenticate || NIL_PROC
    end

    def authorize_with(&block)
      @authorize = block if block
      @authorize || NIL_PROC
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
meter_cat-5.0.1 lib/meter_cat/config.rb
meter_cat-5.0.0 lib/meter_cat/config.rb