Class: AWS::Flow::Templates::ResultWorker::SynchronizedHash
- Inherits:
-
Object
- Object
- AWS::Flow::Templates::ResultWorker::SynchronizedHash
- Defined in:
- lib/aws/templates/result.rb
Overview
Wrapper around a ruby Hash to provide synchronization around making changes to the encapsulated hash.
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize ⇒ SynchronizedHash
constructor
A new instance of SynchronizedHash.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize ⇒ SynchronizedHash
Returns a new instance of SynchronizedHash.
16 17 18 19 |
# File 'lib/aws/templates/result.rb', line 16 def initialize @semaphore = Mutex.new @hash = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
21 22 23 24 25 |
# File 'lib/aws/templates/result.rb', line 21 def method_missing(method, *args) # Not very efficient but ruby structures are not thread # safe in MRI. @semaphore.synchronize{ return @hash.send(method, *args) } end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
14 15 16 |
# File 'lib/aws/templates/result.rb', line 14 def hash @hash end |