Sha256: 804930a151f41eee4602581b8990b895cf3f077a0ea01098bc83c089c75c40ff

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

require 'hull/core_ext/hash'
require 'hull/client'
require 'hull/config'
require 'hull/entity'

module Hull
  extend Config
  class << self
    # Alias for Hull::Client.new
    #
    # @return [Hull::Client]
    def new(options={})
      Hull::Client.new(options)
    end

    def as(user)
      if user.is_a?(String)
        Hull::Client.new({ user_id: user })
      else
        Hull::Client.new({ access_token: self.user_token(user) })
      end
    end

    # Delegate to Hull::Client
    def method_missing(method, *args, &block)
      return super unless new.respond_to?(method)
      new.send(method, *args, &block)
    end

    def respond_to?(method, include_private=false)
      new.respond_to?(method, include_private) || super(method, include_private)
    end

    def log msg, level=:debug
      Hull.logger.send(level.to_sym, "[hull:#{Hull.domain}] #{msg}") if Hull.logger && Hull.logger.respond_to?(level.to_sym)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hullio-0.4.0 lib/hull.rb