Class: Streamforce::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/streamforce/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/streamforce/client.rb', line 5

def initialize(opts = {})
  @host           = opts.fetch(:host, ENV["SALESFORCE_HOST"])
  @username       = opts.fetch(:username, ENV["SALESFORCE_USERNAME"])
  @password       = opts.fetch(:password, ENV["SALESFORCE_PASSWORD"])
  @client_id      = opts.fetch(:client_id, ENV["SALESFORCE_CLIENT_ID"])
  @client_secret  = opts.fetch(:client_secret, ENV["SALESFORCE_CLIENT_SECRET"])
  @security_token = opts.fetch(:security_token, ENV["SALESFORCE_SECURITY_TOKEN"])
  @api_version    = opts.fetch(:api_version, ENV["SALESFORCE_API_VERSION"])

  @logger = opts.fetch(:logger, Logger.new($stdout))
  @logger.level = ENV.fetch("STREAMFORCE_LOG_LEVEL", Logger::INFO)
end

Instance Attribute Details

#api_versionObject (readonly)

Returns the value of attribute api_version.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def api_version
  @api_version
end

#client_idObject (readonly)

Returns the value of attribute client_id.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def client_secret
  @client_secret
end

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def password
  @password
end

#security_tokenObject (readonly)

Returns the value of attribute security_token.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def security_token
  @security_token
end

#usernameObject (readonly)

Returns the value of attribute username.



2
3
4
# File 'lib/streamforce/client.rb', line 2

def username
  @username
end

Instance Method Details

#subscribe(channels = [], &blk) ⇒ Object



18
19
20
# File 'lib/streamforce/client.rb', line 18

def subscribe(channels = [], &blk)
  EM.run { subscribe_to_channels(faye, Array(channels), &blk) }
end