Class: Burg::Once
- Inherits:
-
Object
- Object
- Burg::Once
- Defined in:
- lib/burg/once.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(&block) ⇒ Once
constructor
A new instance of Once.
Constructor Details
#initialize(&block) ⇒ Once
Returns a new instance of Once.
3 4 5 6 |
# File 'lib/burg/once.rb', line 3 def initialize(&block) @block = block @mutex = Mutex.new end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/burg/once.rb', line 8 def call @mutex&.synchronize do return unless @mutex @block.call @mutex = nil end end |