Sha256: 0ff4359818a0f75ad6922207d4bd24076e2fb32e8ee219ce9cb5bd340b44e9a2

Contents?: true

Size: 686 Bytes

Versions: 3

Compression:

Stored size: 686 Bytes

Contents

module Raterr
  class PeriodBuilder

    attr_reader :request, :period, :options

    class << self
      def call(request, options)
        new(request, options).build
      end
    end

    def initialize(request, options)
      @period = options[:period] || DEFAULTS[:period]
      @request = request
      @options = options
    end

    def build
      klass = case period
        when :minute
          Raterr::Minute
        when :hour
          Raterr::Hour
        when :day
          Raterr::Day
        else
          raise "Invalid limit period, available options are: #{Raterr::AVAILABLE_PERIODS.join(', ')}"
        end
      klass.new(request, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
raterr-0.1.2 lib/raterr/period_builder.rb
raterr-0.1.1 lib/raterr/period_builder.rb
raterr-0.1.0 lib/raterr/period_builder.rb