Module: HermesMessengerOfTheGods::Concerns::Message
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Model, EndpointBuilder::Helpers, LoggingHelpers
- Defined in:
- lib/hermes_messenger_of_the_gods/concerns/message.rb
Instance Attribute Summary collapse
-
#original_message ⇒ Object
Returns the value of attribute original_message.
-
#source_endpoint ⇒ Object
Returns the value of attribute source_endpoint.
Instance Method Summary collapse
- #_build_for_transmission ⇒ Object
- #attributes ⇒ Object
- #dispatch ⇒ Object
- #dispatch!(endpoint_args: {}) ⇒ Object
- #inspect ⇒ Object
- #retry_at(future_time_or_seconds_in_future) ⇒ Object
- #to_message ⇒ Object
- #validate! ⇒ Object
Instance Attribute Details
#original_message ⇒ Object
Returns the value of attribute original_message.
16 17 18 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 16 def @original_message end |
#source_endpoint ⇒ Object
Returns the value of attribute source_endpoint.
16 17 18 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 16 def source_endpoint @source_endpoint end |
Instance Method Details
#_build_for_transmission ⇒ Object
50 51 52 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 50 def _build_for_transmission end |
#attributes ⇒ Object
58 59 60 61 62 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 58 def attributes (self.class._defined_attributes || []).each.with_object({}) do |attr, hsh| hsh[attr] = send(attr) end end |
#dispatch ⇒ Object
22 23 24 25 26 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 22 def dispatch dispatch! rescue StandardError false end |
#dispatch!(endpoint_args: {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 35 def dispatch!(endpoint_args: {}) validate! begin endpoint.dispatch!(self, endpoint_args) unless HermesMessengerOfTheGods.config.stub_dispatch rescue StandardError => e say_error(e) raise HermesMessengerOfTheGods::MessageDispatchFailed, e. ensure endpoint.teardown end true end |
#inspect ⇒ Object
64 65 66 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 64 def inspect "<#{self.class}: #{attributes}>" end |
#retry_at(future_time_or_seconds_in_future) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 28 def retry_at(future_time_or_seconds_in_future) raise 'unable to set visiblity' if source_endpoint.nil? || .nil? raise "endpoint type doesn't support setting execution time" unless source_endpoint.respond_to?(:set_reexecution_time) source_endpoint.set_reexecution_time(, future_time_or_seconds_in_future) end |
#to_message ⇒ Object
54 55 56 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 54 def attributes end |
#validate! ⇒ Object
18 19 20 |
# File 'lib/hermes_messenger_of_the_gods/concerns/message.rb', line 18 def validate! raise HermesMessengerOfTheGods::ValidationError.new(self) unless valid? end |