Class: Philotic::Publisher
- Inherits:
-
Object
- Object
- Philotic::Publisher
- Defined in:
- lib/philotic/publisher.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#log_message_handler ⇒ Object
Returns the value of attribute log_message_handler.
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(connection) ⇒ Publisher
constructor
A new instance of Publisher.
- #logger ⇒ Object
- #normalize_payload_times(payload) ⇒ Object
- #publish(message) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Publisher
10 11 12 |
# File 'lib/philotic/publisher.rb', line 10 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
7 8 9 |
# File 'lib/philotic/publisher.rb', line 7 def connection @connection end |
#log_message_handler ⇒ Object
Returns the value of attribute log_message_handler.
8 9 10 |
# File 'lib/philotic/publisher.rb', line 8 def end |
Instance Method Details
#config ⇒ Object
18 19 20 |
# File 'lib/philotic/publisher.rb', line 18 def config connection.config end |
#logger ⇒ Object
14 15 16 |
# File 'lib/philotic/publisher.rb', line 14 def logger connection.logger end |
#normalize_payload_times(payload) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/philotic/publisher.rb', line 35 def normalize_payload_times(payload) payload.each do |k, v| if v.respond_to?(:utc) payload[k] = v.utc elsif v.respond_to?(:to_utc) payload[k] = v.to_utc end end end |
#publish(message) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/philotic/publisher.rb', line 22 def publish() = {headers: .headers} .merge!(.) if . begin .published = _publish(.payload, ) rescue => e .publish_error = e logger.error e. raise e if config.raise_error_on_publish end end |