Class: SynchronizedDelegator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SynchronizedDelegator
- Defined in:
- lib/thread_safe/synchronized_delegator.rb
Instance Method Summary collapse
-
#initialize ⇒ SynchronizedDelegator
constructor
A new instance of SynchronizedDelegator.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ SynchronizedDelegator
Returns a new instance of SynchronizedDelegator.
20 21 22 23 |
# File 'lib/thread_safe/synchronized_delegator.rb', line 20 def initialize(*) super @mutex = Mutex.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/thread_safe/synchronized_delegator.rb', line 25 def method_missing(m, *args, &block) begin mutex = @mutex mutex.lock super ensure mutex.unlock end end |