Class: Pecorino::LeakyBucket::ConditionalFillupResult

Inherits:
State
  • Object
show all
Defined in:
lib/pecorino/leaky_bucket.rb

Overview

Same as ‘State` but also communicates whether the write has been permitted or not. A conditional fillup may refuse a write if it would make the bucket overflow

Instance Attribute Summary

Attributes inherited from State

#level

Instance Method Summary collapse

Methods inherited from State

#full?

Constructor Details

#initialize(level, is_full, accepted) ⇒ ConditionalFillupResult

Returns a new instance of ConditionalFillupResult.



52
53
54
55
# File 'lib/pecorino/leaky_bucket.rb', line 52

def initialize(level, is_full, accepted)
  super(level, is_full)
  @accepted = !!accepted
end

Instance Method Details

#accepted?Boolean

Tells whether the bucket did accept the requested fillup

Returns:

  • (Boolean)


59
60
61
# File 'lib/pecorino/leaky_bucket.rb', line 59

def accepted?
  @accepted
end