Sha256: 72a0011fa09208db719403c094152ad45a5de7bc254732be94a3606ead8f7800

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

module CustomMethods
  # @private
  def extended(base)
    # FIXME: Useless time consuming (especially for arrays)...
    base.class.send(:attr_accessor, :_client) unless base.respond_to?(:_client)
  end

  # @private
  # By extending CustomMethods in YourModule, you are able to call
  # YourModule.apply_to(object_or_array) to add YourModule methods to the
  # object or to all objects in the array.
  def apply_to(receiver, client_opts)
    case receiver
    when Array
      receiver.each{|a| a.extend self; a._client = client_opts[:client]}
    when Hashie::Mash
      receiver.extend self; receiver._client = client_opts[:client]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cloud_connect-3.2.0 lib/cloud_connect/client/custom_methods.rb
cloud_connect-3.1.0 lib/cloud_connect/client/custom_methods.rb
cloud_connect-3.0.3 lib/cloud_connect/client/custom_methods.rb