Sha256: 296f5c6cd4ae23fb207ac6a64beae37ab241f0a021f189ae2eae89d97b9549a5

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require 'active_support/core_ext/class'
require 'active_support/core_ext/module'

module Eloqua

  autoload :Api, 'eloqua/api'
  autoload :Entity, 'eloqua/entity'
  autoload :Asset, 'eloqua/asset'
  autoload :RemoteObject, 'eloqua/remote_object'
  autoload :Query, 'eloqua/query'

  mattr_accessor :user, :password

  def self.configure(&block)
    yield self
  end

  def self.authenticate(user, password)
    self.user = user
    self.password = password
  end

  def self.format_results_for_array(results, *keys)
    max_depth = keys.length
    depth = 0
    keys.each do |key|
      if(results.has_key?(key))
        depth += 1
        results = results[key]
      end
    end
    if(depth == max_depth && !results.is_a?(Array))
      results = [results]
    end
    results
  end

  def self.delegate_with_args(from_klass, to_klass, methods, methods_to_argument)
    argument_string = methods_to_argument.join(', ')
    methods.each do |__method_name|
      from_klass.module_eval(<<-RUBY)
        def self.#{__method_name}(*args, &block)
          #{to_klass}.__send__(#{__method_name.inspect}, #{argument_string}, *args, &block)
        end
      RUBY
    end

  end


end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eloqua-1.2.1 lib/eloqua.rb
eloqua-1.2.0 lib/eloqua.rb
eloqua-1.1.4 lib/eloqua.rb
eloqua-1.1.3 lib/eloqua.rb
eloqua-1.1.2 lib/eloqua.rb
eloqua-1.1.1 lib/eloqua.rb
eloqua-1.1.0 lib/eloqua.rb