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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



9
10
11
12
# File 'lib/capybara/server/middleware.rb', line 9

def initialize
  @value = 0
  @mutex = Mutex.new
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#decrementObject



18
19
20
# File 'lib/capybara/server/middleware.rb', line 18

def decrement
  @mutex.synchronize { @value -= 1 }
end

#incrementObject



14
15
16
# File 'lib/capybara/server/middleware.rb', line 14

def increment
  @mutex.synchronize { @value += 1 }
end