Sha256: 1d9bd419fdb5cf778a3a7b55688156964854979579d3a08c5ec64dbaee51addd

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 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-0.0.7 lib/meter_cat/config.rb
meter_cat-0.0.6 lib/meter_cat/config.rb