Sha256: e0e8cc57f73e9c97cfc020624e71554c84665cbf247ec1a00996638a10268604
Contents?: true
Size: 1.15 KB
Versions: 108
Compression:
Stored size: 1.15 KB
Contents
module Pageflow class Quota class ExhaustedError < RuntimeError attr_reader :quota def initialize(quota) @quota = quota end end class ExceededError < ExhaustedError; end attr_reader :name, :account def initialize(name, account) @name = name @account = account end def state raise(NotImplementedError, 'Quota#state must be implemented and return either "available", "exhausted" or "exceeded".') end def state_description raise(NotImplementedError, 'Quota#state_description must be implemented.') end def available? state == 'available' end def exhausted? !available? end def exceeded? state == 'exceeded' end def verify_available! raise(ExhaustedError.new(self), "Quota '#{name}' exhausted.") unless available? end def verify_not_exceeded! raise(ExceededError.new(self), "Quota '#{name}' exceeded.") if exceeded? end def assume(assumptions) self end class Unlimited < Quota def state 'available' end def state_description nil end end end end
Version data entries
108 entries across 108 versions & 1 rubygems