Class: Itly::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/itly/event.rb

Overview

Event object used to communicate data between Itly core SDK and its plugins

Properties: name: The event’s name. properties: The event’s properties. id: The event’s unique ID in Iteratively. version: The event’s version, e.g. 2.0.1. plugins: Granular Event Destinations: to control to which plugin to forward this event to

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, properties: {}, id: nil, version: nil, plugins: {}) ⇒ Event

Create a new Event object

Parameters:

  • name: (String)

    The event’s name.

  • properties: (Hash) (defaults to: {})

    The event’s properties.

  • id: (String) (defaults to: nil)

    The event’s unique ID in Iteratively.

  • version: (String) (defaults to: nil)

    The event’s version, e.g. 2.0.1.

  • plugins: (Hash) (defaults to: {})

    Granular Event Destinations: to control to which plugin to forward this event to



26
27
28
29
30
31
32
# File 'lib/itly/event.rb', line 26

def initialize(name:, properties: {}, id: nil, version: nil, plugins: {})
  @name = name
  @properties = properties
  @id = id
  @version = version
  @plugins = plugins.transform_keys(&:to_s)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/itly/event.rb', line 15

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/itly/event.rb', line 15

def name
  @name
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



15
16
17
# File 'lib/itly/event.rb', line 15

def plugins
  @plugins
end

#propertiesObject (readonly)

Returns the value of attribute properties.



15
16
17
# File 'lib/itly/event.rb', line 15

def properties
  @properties
end

#versionObject (readonly)

Returns the value of attribute version.



15
16
17
# File 'lib/itly/event.rb', line 15

def version
  @version
end

Instance Method Details

#==(other) ⇒ True/False

Compare the object to another

Parameters:

  • other: (Object)

    the object to compare to

Returns:

  • (True/False)

    are the objects similar



53
54
55
56
# File 'lib/itly/event.rb', line 53

def ==(other)
  other.class == self.class && [name, properties, id, version] ==
    [other.name, other.properties, other.id, other.version]
end

#to_sString

Describe the object

Returns:

  • (String)

    the object description



39
40
41
42
43
44
# File 'lib/itly/event.rb', line 39

def to_s
  str = "#<#{self.class.name}: name: #{name}, "
  str += "id: #{id}, " unless id.nil?
  str += "version: #{version}, " unless version.nil?
  str + "properties: #{properties}>"
end