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

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.


15
16
17
# File 'lib/salesforce_streamer/push_topic.rb', line 15

def id=(value)
  @id = value
end

Class Method Details

.prepare_handler_proc(constant) ⇒ Object


52
53
54
55
56
57
58
59
60
# File 'lib/salesforce_streamer/push_topic.rb', line 52

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


46
47
48
49
50
# File 'lib/salesforce_streamer/push_topic.rb', line 46

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

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

Instance Method Details

#attributesObject


25
26
27
# File 'lib/salesforce_streamer/push_topic.rb', line 25

def attributes
  self.class.dry_initializer.public_attributes self
end

#handle(message) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/salesforce_streamer/push_topic.rb', line 17

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