Module: Ihasa

Defined in:
lib/ihasa.rb,
lib/ihasa/lua.rb,
lib/ihasa/bucket.rb,
lib/ihasa/version.rb,
lib/ihasa/bucket/implementation.rb,
lib/ihasa/bucket/legacy_implementation.rb

Overview

Ihasa module. Root of the Ihasa::Bucket class

Defined Under Namespace

Modules: Lua, Version Classes: Bucket

Constant Summary collapse

NOK =
0
OK =
1
OPTIONS =
%i(rate burst last allowance).freeze
DEFAULT_PREFIX =
'IHAB'.freeze

Class Method Summary collapse

Class Method Details

.bucket(rate: 5, burst: 10, prefix: DEFAULT_PREFIX, redis: default_redis) ⇒ Object



23
24
25
# File 'lib/ihasa.rb', line 23

def bucket(rate: 5, burst: 10, prefix: DEFAULT_PREFIX, redis: default_redis)
  Bucket.create(rate, burst, prefix, redis)
end

.default_redisObject



14
15
16
17
18
19
20
# File 'lib/ihasa.rb', line 14

def default_redis
  @redis ||= if ENV['REDIS_URL']
               Redis.new url: ENV['REDIS_URL']
             else
               Redis.new
             end
end