Sha256: 909856ab1580ffc0ed57dd3a39cca2fafcf0eac56f24dc289b98e88df20ef94d

Contents?: true

Size: 725 Bytes

Versions: 2

Compression:

Stored size: 725 Bytes

Contents

require 'lhm/throttler/time'

module Lhm
  module Throttler
    CLASSES = { :time_throttler => Throttler::Time }

    def throttler
      @throttler ||= Throttler::Time.new
    end

    def setup_throttler(type, options = {})
      @throttler = Factory.create_throttler(type, options)
    end

    class Factory
      def self.create_throttler(type, options = {})
        case type
        when Lhm::Command
          type
        when Symbol
          CLASSES[type].new(options)
        when String
          CLASSES[type.to_sym].new(options)
        when Class
          type.new(options)
        else
          raise ArgumentError, 'type argument must be a Symbol, String or Class'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lhm-2.2.0 lib/lhm/throttler.rb
lhm-2.1.0 lib/lhm/throttler.rb