Class: Itly::Plugin::Segment::CallOptions

Inherits:
Itly::PluginCallOptions
  • Object
show all
Defined in:
lib/itly/plugin/segment/call_options.rb

Overview

Segment specific plugin options class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callback: nil, integrations: nil, context: nil, message_id: nil, timestamp: nil, anonymous_id: nil) ⇒ CallOptions

Returns a new instance of CallOptions.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/itly/plugin/segment/call_options.rb', line 13

def initialize(
  callback: nil, integrations: nil, context: nil, message_id: nil, timestamp: nil, anonymous_id: nil
)
  super()
  @integrations = integrations
  @callback = callback
  @context = context
  @message_id = message_id
  @timestamp = timestamp
  @anonymous_id = anonymous_id
end

Instance Attribute Details

#anonymous_idObject (readonly)

Returns the value of attribute anonymous_id.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def anonymous_id
  @anonymous_id
end

#callbackObject (readonly)

Returns the value of attribute callback.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def callback
  @callback
end

#contextObject (readonly)

Returns the value of attribute context.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def context
  @context
end

#integrationsObject (readonly)

Returns the value of attribute integrations.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def integrations
  @integrations
end

#message_idObject (readonly)

Returns the value of attribute message_id.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def message_id
  @message_id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



11
12
13
# File 'lib/itly/plugin/segment/call_options.rb', line 11

def timestamp
  @timestamp
end

Instance Method Details

#to_hashHash

Return all properties to be passed to the client While excluding the ‘callback` property

Returns:

  • (Hash)

    properties



31
32
33
34
35
# File 'lib/itly/plugin/segment/call_options.rb', line 31

def to_hash
  %w[integrations context message_id timestamp anonymous_id].each_with_object({}) do |prop, hash|
    hash[prop.to_sym] = send(prop) unless send(prop).nil?
  end
end

#to_sString

Get the plugin description, for logs

Returns:

  • (String)

    description



42
43
44
45
46
47
48
# File 'lib/itly/plugin/segment/call_options.rb', line 42

def to_s
  class_name = self.class.name.split('::').last
  props = %w[integrations context message_id timestamp anonymous_id].collect do |prop|
    " #{prop}: #{send prop}" unless send(prop).nil?
  end.compact
  "#<Segment::#{class_name} callback: #{callback.nil? ? 'nil' : 'provided'}#{props.join}>"
end