Method: CloudConnect::Client#enhance

Defined in:
lib/cloud_connect/client.rb

#enhance(object, with_opts) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cloud_connect/client.rb', line 24

def enhance(object, with_opts)
  # @private
  # Add custom methods to provided object(s).
  # This method provides syntaxic suggar upon <tt>Module.apply_to(object)</tt>,
  # allowing you to write <tt>enhance object, with: Module</tt>
  #
  # @param object [Object] An Object or Array of Objects to enhance.
  # @param with_opts [Hash] Customizable set of options.
  # @options with_opts [Module] :with Module to include.
  # @return [Object] Enhanced initial object.
  # @example Enhance an instance of Hashie::Mash with methods defined in the AssetMethods module
  #   enhance( Hashie::Mash.new, :with => AssetMethods)
  object.tap do |obj|
    with_opts[:with].apply_to(obj, client: self)
  end
end