Module: ThreeScale::Backend::Period

Included in:
Granularity, Instance
Defined in:
lib/3scale/backend/period/cache.rb,
lib/3scale/backend/period/period.rb,
lib/3scale/backend/period/boundary.rb

Defined Under Namespace

Modules: Boundary, Granularity, Instance Classes: Cache

Constant Summary collapse

Unknown =
Class.new StandardError do
  def initialize(granularity)
    super "unknown period granularity '#{granularity.inspect}'"
  end
end
SYMBOLS =
LINKS.keys.freeze
SYMBOLS_DESC =
SYMBOLS.reverse.freeze
ALL =

All period granularities, sorted asc by duration (as defined in SYMBOLS)

SYMBOLS.map do |p|
  name = p.capitalize
  # create Period::Month()
  define_singleton_method name do |*args|
    Period.from p, *args
  end
  const_set(name, create_granularity_class(p).freeze)
end.freeze
ALL_DESC =
ALL.reverse.freeze
HASH =
Hash[SYMBOLS.zip ALL].freeze