Class: Litmus::Instant::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/litmus/instant.rb

Overview

This allows us to create API Client instances, useful primarily with OAuth, to set a token for each authorized user in a thread safe manner All the class methods on ‘Instant` are made available on the instance

Class Method Summary collapse

Class Method Details

.new(oauth_token: nil, api_key: nil) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/litmus/instant.rb', line 55

def new(oauth_token: nil, api_key: nil)
  Class.new(Instant) do |klass|
    extend Forwardable

    def_delegators(
      :"self.class",
      *(Litmus::Instant.methods - Object.methods)
    )

    klass.oauth_token = oauth_token if oauth_token
    klass.api_key = api_key if api_key
  end.new
end