Class: Segment::Analytics

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
'2.2.5'

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.



19
20
21
22
# File 'lib/segment/analytics.rb', line 19

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



24
25
26
27
28
29
30
# File 'lib/segment/analytics.rb', line 24

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

Instance Method Details

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

Returns:

  • (Boolean)


32
33
34
# File 'lib/segment/analytics.rb', line 32

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