Class: Orthrus::RemoteOptions

Inherits:
Hash
  • Object
show all
Defined in:
lib/orthrus/remote_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RemoteOptions

Returns a new instance of RemoteOptions.

Parameters:

  • options (Hash) (defaults to: {})

    to be set as remote options



4
5
6
# File 'lib/orthrus/remote_options.rb', line 4

def initialize(options = {})
  replace(options)
end

Instance Method Details

#smart_merge(hash) ⇒ nil, RemoteOptions

Merge the given hash and its subhashes.

Parameters:

  • other_hash (Hash)

    to merge against

Returns:



11
12
13
14
15
16
# File 'lib/orthrus/remote_options.rb', line 11

def smart_merge(hash)
  return self if hash.nil?
  merge(hash) do |key, o, n|
    o.is_a?(Hash) && n.is_a?(Hash) ? o.merge(n) : n
  end
end

#smart_merge!(other_hash) ⇒ Object

Perform smart merge and replace the current content



20
21
22
# File 'lib/orthrus/remote_options.rb', line 20

def smart_merge!(other_hash)
  replace(smart_merge(other_hash))
end