Class: PlaywrightOnRails::Server::Middleware::Counter
- Inherits:
-
Object
- Object
- PlaywrightOnRails::Server::Middleware::Counter
- Defined in:
- lib/playwright-on-rails/server/middleware.rb
Instance Method Summary collapse
- #decrement(uri) ⇒ Object
- #increment(uri) ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #positive? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
5 6 7 8 |
# File 'lib/playwright-on-rails/server/middleware.rb', line 5 def initialize @value = [] @mutex = Mutex.new end |
Instance Method Details
#decrement(uri) ⇒ Object
14 15 16 |
# File 'lib/playwright-on-rails/server/middleware.rb', line 14 def decrement(uri) @mutex.synchronize { @value.delete_at(@value.index(uri) || @value.length) } end |
#increment(uri) ⇒ Object
10 11 12 |
# File 'lib/playwright-on-rails/server/middleware.rb', line 10 def increment(uri) @mutex.synchronize { @value.push(uri) } end |
#positive? ⇒ Boolean
18 19 20 |
# File 'lib/playwright-on-rails/server/middleware.rb', line 18 def positive? @mutex.synchronize { @value.length.positive? } end |
#value ⇒ Object
22 23 24 |
# File 'lib/playwright-on-rails/server/middleware.rb', line 22 def value @mutex.synchronize { @value.dup } end |