Class: LucidIntercom::RenderSnippet

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid_intercom/render_snippet.rb

Constant Summary collapse

TEMPLATE =
ERB.new(File.read("#{__dir__}/snippet.html.erb")).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shop_attributes = {}, app_attributes = {}, credentials = LucidIntercom.credentials) ⇒ RenderSnippet

Leave arguments unset for unauthenticated visitors.

Parameters:

  • (defaults to: LucidIntercom.credentials)

See Also:



18
19
20
21
# File 'lib/lucid_intercom/render_snippet.rb', line 18

def initialize(shop_attributes = {}, app_attributes = {}, credentials = LucidIntercom.credentials)
  @credentials = credentials
  @attributes = Attributes.new(shop_attributes, app_attributes, credentials) if shop_attributes.empty?
end

Instance Attribute Details

#attributesLucidIntercom::Attributes (readonly)

Returns:



24
25
26
# File 'lib/lucid_intercom/render_snippet.rb', line 24

def attributes
  @attributes
end

#credentialsLucidIntercom::Credentials (readonly)

Returns:



26
27
28
# File 'lib/lucid_intercom/render_snippet.rb', line 26

def credentials
  @credentials
end

Instance Method Details

#callString

Returns the rendered HTML.

Returns:

  • the rendered HTML



31
32
33
# File 'lib/lucid_intercom/render_snippet.rb', line 31

def call
  TEMPLATE.result(binding)
end