Class: CypressRails::Server::Middleware::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/cypress-rails/server/middleware.rb

Instance Method Summary collapse

Constructor Details

#initializeCounter

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/cypress-rails/server/middleware.rb', line 18

def positive?
  @mutex.synchronize { @value.length.positive? }
end

#valueObject



22
23
24
# File 'lib/cypress-rails/server/middleware.rb', line 22

def value
  @mutex.synchronize { @value.dup }
end