Class: Leakybucket::Manager
- Inherits:
-
Object
- Object
- Leakybucket::Manager
- Defined in:
- lib/leakybucket/manager.rb
Instance Attribute Summary collapse
-
#buckets ⇒ Object
Returns the value of attribute buckets.
-
#default_options ⇒ Object
Returns the value of attribute default_options.
Instance Method Summary collapse
- #create_bucket(options = {}) ⇒ Object
- #generate_key ⇒ Object
-
#initialize(default_options = {}) ⇒ Manager
constructor
A new instance of Manager.
- #remove_bucket(key) ⇒ Object
Constructor Details
#initialize(default_options = {}) ⇒ Manager
Returns a new instance of Manager.
7 8 9 10 |
# File 'lib/leakybucket/manager.rb', line 7 def initialize( = {}) self. = self.buckets = {} end |
Instance Attribute Details
#buckets ⇒ Object
Returns the value of attribute buckets.
5 6 7 |
# File 'lib/leakybucket/manager.rb', line 5 def buckets @buckets end |
#default_options ⇒ Object
Returns the value of attribute default_options.
5 6 7 |
# File 'lib/leakybucket/manager.rb', line 5 def @default_options end |
Instance Method Details
#create_bucket(options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/leakybucket/manager.rb', line 16 def create_bucket( = {}) key = [:key] || generate_key b = Leakybucket::Bucket.new(.merge(), key) buckets[key] = b b end |
#generate_key ⇒ Object
12 13 14 |
# File 'lib/leakybucket/manager.rb', line 12 def generate_key SecureRandom.uuid end |
#remove_bucket(key) ⇒ Object
23 24 25 |
# File 'lib/leakybucket/manager.rb', line 23 def remove_bucket(key) buckets.delete(key) end |