class SalesforceStreamer::PushTopic
Models the PushTopic
object for both Restforce and Streamer
Attributes
id[W]
Private Class Methods
prepare_handler_proc(constant)
click to toggle source
# 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)
click to toggle source
# File lib/salesforce_streamer/push_topic.rb, line 46 def strip_spaces(str) fail(NilQueryError, @name) unless str str.gsub(/\s+/, ' ') end
Public Instance Methods
attributes()
click to toggle source
# File lib/salesforce_streamer/push_topic.rb, line 25 def attributes self.class.dry_initializer.public_attributes self end
handle(message)
click to toggle source
# 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
Private Instance Methods
message_middleware()
click to toggle source
# File lib/salesforce_streamer/push_topic.rb, line 41 def message_middleware Configuration.instance.middleware_runner(handler) end
validate!()
click to toggle source
# File lib/salesforce_streamer/push_topic.rb, line 31 def validate! fail(PushTopicNameTooLongError, @name) if @name.size > 25 @handler = Object.const_get(@handler) true rescue NameError, TypeError => e message = "handler=#{@handler} exception=#{e}" raise(PushTopicHandlerMissingError, message) end