Class: SalesforceStreamer::PushTopic

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

Overview

Models the PushTopic object for both Restforce and Streamer

Constant Summary collapse

DEFAULT_API_VERSION =
ENV.fetch('SALESFORCE_API_VERSION', '58.0')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#id=(value) ⇒ Object (writeonly)

Sets the attribute id

Parameters:

  • value

    the value to set the attribute id to.



17
18
19
# File 'lib/salesforce_streamer/push_topic.rb', line 17

def id=(value)
  @id = value
end

Class Method Details

.prepare_handler_proc(constant) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/salesforce_streamer/push_topic.rb', line 56

def prepare_handler_proc(constant)
  if constant.respond_to? :call
    constant
  elsif constant.respond_to? :perform_async
    proc { |message| constant.perform_async(message) }
  else
    fail(UnprocessableHandlerError, constant)
  end
end

.strip_spaces(str) ⇒ Object



50
51
52
53
54
# File 'lib/salesforce_streamer/push_topic.rb', line 50

def strip_spaces(str)
  fail(NilQueryError, @name) unless str

  str.gsub(/\s+/, ' ')
end

Instance Method Details

#attributesObject



29
30
31
# File 'lib/salesforce_streamer/push_topic.rb', line 29

def attributes
  self.class.dry_initializer.public_attributes self
end

#handle(message) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/salesforce_streamer/push_topic.rb', line 19

def handle(message)
  message['topic'] = @name
  message['hostname'] = ENV['HOSTNAME']
  message['k8s_pod_name'] = ENV['K8S_POD_NAME']
  message_middleware.call(message)
rescue StandardError => e
  Log.error e
  Configuration.instance.exception_adapter.call e
end