Class: Clearbit::Analytics

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/clearbit/analytics.rb,
lib/clearbit/analytics/utils.rb,
lib/clearbit/analytics/client.rb,
lib/clearbit/analytics/worker.rb,
lib/clearbit/analytics/logging.rb,
lib/clearbit/analytics/request.rb,
lib/clearbit/analytics/defaults.rb,
lib/clearbit/analytics/response.rb,
lib/clearbit/analytics/field_parser.rb,
lib/clearbit/analytics/message_batch.rb,
lib/clearbit/analytics/backoff_policy.rb

Defined Under Namespace

Modules: Defaults, Logging, Utils Classes: BackoffPolicy, Client, FieldParser, MessageBatch, PrefixedLogger, Request, Response, Worker

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #logger

Constructor Details

#initialize(options = {}) ⇒ Analytics

Initializes a new instance of Client, to which all method calls are proxied.

Parameters:

Options Hash (options):

  • :stub (Boolean) — default: false

    If true, requests don’t hit the server and are stubbed to be successful.



27
28
29
30
# File 'lib/clearbit/analytics.rb', line 27

def initialize(options = {})
  Request.stub = options[:stub] if options.has_key?(:stub)
  @client = Clearbit::Analytics::Client.new options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(message, *args, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/clearbit/analytics.rb', line 32

def method_missing(message, *args, &block)
  if @client.respond_to? message
    @client.send message, *args, &block
  else
    super
  end
end

Class Method Details

.identify(args) ⇒ Object

Proxy identify through to a client instance, in order to keep the client consistent with how the other Clearbit APIs are accessed



14
15
16
17
18
# File 'lib/clearbit/analytics.rb', line 14

def self.identify(args)
  analytics = new(write_key: Clearbit.key)
  analytics.identify(args)
  analytics.flush
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/clearbit/analytics.rb', line 40

def respond_to_missing?(method_name, include_private = false)
  @client.respond_to?(method_name) || super
end