Module: OptionsHelper
- Included in:
- MessageQueue::Consumer, MessageQueue::Producer
- Defined in:
- lib/message_queue/options_helper.rb
Instance Method Summary collapse
-
#compute_values(options = {}) ⇒ Object
Internal: Recursively compute the value of a Hash if it responds to :call.
-
#deep_clone(options = {}) ⇒ Object
Internal: Deep clone a Hash.
Instance Method Details
#compute_values(options = {}) ⇒ Object
Internal: Recursively compute the value of a Hash if it responds to :call
options - The Hash options to compute value for
Returns the Hash with values computed if responding to :call
17 18 19 20 21 22 23 24 25 |
# File 'lib/message_queue/options_helper.rb', line 17 def compute_values( = {}) .each do |k, v| if v.is_a?(Hash) compute_values(v) else [k] = v.call if v.respond_to?(:call) end end end |
#deep_clone(options = {}) ⇒ Object
Internal: Deep clone a Hash. Compute the values in the Hash if responding to :call
options - The Hash options to clone
Returns the cloned Hash with values computed if responding to :call
7 8 9 10 |
# File 'lib/message_queue/options_helper.rb', line 7 def deep_clone( = {}) compute_values() Marshal.load(Marshal.dump()) # deep cloning options end |