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.



43
44
45
46
# File 'lib/clearbit/analytics.rb', line 43

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



48
49
50
51
52
53
54
# File 'lib/clearbit/analytics.rb', line 48

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

Class Method Details

.group(args) ⇒ Object

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



30
31
32
33
34
# File 'lib/clearbit/analytics.rb', line 30

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

.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

.page(args) ⇒ Object

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



22
23
24
25
26
# File 'lib/clearbit/analytics.rb', line 22

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

Instance Method Details

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

Returns:

  • (Boolean)


56
57
58
# File 'lib/clearbit/analytics.rb', line 56

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