Class: Capybara::Server::Middleware::Counter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/server/middleware.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initializeCounter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Counter


7
8
9
10
# File 'lib/capybara/server/middleware.rb', line 7

def initialize
  @value = []
  @mutex = Mutex.new
end

Instance Method Details

#decrement(uri) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


16
17
18
# File 'lib/capybara/server/middleware.rb', line 16

def decrement(uri)
  @mutex.synchronize { @value.delete_at(@value.index(uri) || @value.length) }
end

#increment(uri) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


12
13
14
# File 'lib/capybara/server/middleware.rb', line 12

def increment(uri)
  @mutex.synchronize { @value.push(uri) }
end

#positive?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


20
21
22
# File 'lib/capybara/server/middleware.rb', line 20

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

#valueObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


24
25
26
# File 'lib/capybara/server/middleware.rb', line 24

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