Class: LucidIntercom::Event

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/lucid_intercom/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.event(event_name) ⇒ Object

Set the event name for the subclass.

Examples:

event :changed_plan

Parameters:

  • event_name (String, #to_s)


29
30
31
32
33
# File 'lib/lucid_intercom/event.rb', line 29

def self.event(event_name)
  define_method(:event_name) do
    "#{LucidIntercom.app_prefix}_#{event_name}"
  end
end

Instance Method Details

#app_dataHash

Additional custom attributes related to the event (unprefixed).

Examples:

{plan: 'free'}
{plan: nil}

Returns:

  • (Hash)


64
65
66
# File 'lib/lucid_intercom/event.rb', line 64

def app_data
  {}
end

#companyCompanyAttributes

Returns:



15
# File 'lib/lucid_intercom/event.rb', line 15

option :company, default: proc { CompanyAttributes.new(shopify_data) }

#company_customCompanyCustomAttributes



17
# File 'lib/lucid_intercom/event.rb', line 17

option :company_custom, default: proc { CompanyCustomAttributes.new(shopify_data, app_data) }

#event_metadataHash

This method is abstract.

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/lucid_intercom/event.rb', line 49

def 
  raise NotImplementedError
end

#event_nameString

This method is abstract.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/lucid_intercom/event.rb', line 40

def event_name
  raise NotImplementedError
end

#shopify_dataHash

Returns shop attributes as returned by the Shopify API.

Returns:

  • (Hash)

    shop attributes as returned by the Shopify API



13
# File 'lib/lucid_intercom/event.rb', line 13

param :shopify_data

#userUserAttributes

Returns:



19
# File 'lib/lucid_intercom/event.rb', line 19

option :user, default: proc { UserAttributes.new(shopify_data) }

#user_idHash

Returns:

  • (Hash)


71
72
73
74
75
# File 'lib/lucid_intercom/event.rb', line 71

def user_id
  {
    user.id_key => user.id,
  }
end