Class: CypressRails::Server::Middleware::Counter
- Inherits:
-
Object
- Object
- CypressRails::Server::Middleware::Counter
- Defined in:
- lib/cypress-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/cypress-rails/server/middleware.rb', line 5 def initialize @value = [] @mutex = Mutex.new end |
Instance Method Details
#decrement(uri) ⇒ Object
14 15 16 |
# File 'lib/cypress-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/cypress-rails/server/middleware.rb', line 10 def increment(uri) @mutex.synchronize { @value.push(uri) } end |
#positive? ⇒ Boolean
18 19 20 |
# File 'lib/cypress-rails/server/middleware.rb', line 18 def positive? @mutex.synchronize { @value.length.positive? } end |
#value ⇒ Object
22 23 24 |
# File 'lib/cypress-rails/server/middleware.rb', line 22 def value @mutex.synchronize { @value.dup } end |