Module: Cloudenvoy::Publisher::ClassMethods
- Defined in:
- lib/cloudenvoy/publisher.rb
Overview
Module class methods
Instance Method Summary collapse
-
#cloudenvoy_options(opts = {}) ⇒ Hash
Set the publisher runtime options.
-
#cloudenvoy_options_hash ⇒ Hash
Return the publisher runtime options.
-
#default_topic ⇒ String
Return the default topic this publisher publishes to.
-
#publish(*args) ⇒ Cloudenvoy::Message
Format and publish objects to Pub/Sub.
-
#setup ⇒ Cloudenvoy::Topic
Setup the default topic for this publisher.
Instance Method Details
#cloudenvoy_options(opts = {}) ⇒ Hash
Set the publisher runtime options.
47 48 49 50 |
# File 'lib/cloudenvoy/publisher.rb', line 47 def (opts = {}) opt_list = opts&.map { |k, v| [k.to_sym, v] } || [] # symbolize = Hash[opt_list] end |
#cloudenvoy_options_hash ⇒ Hash
Return the publisher runtime options.
57 58 59 |
# File 'lib/cloudenvoy/publisher.rb', line 57 def || {} end |
#default_topic ⇒ String
Return the default topic this publisher publishes to. Raises an error if no default topic has been defined.
67 68 69 |
# File 'lib/cloudenvoy/publisher.rb', line 67 def default_topic [:topic] end |
#publish(*args) ⇒ Cloudenvoy::Message
Format and publish objects to Pub/Sub.
78 79 80 |
# File 'lib/cloudenvoy/publisher.rb', line 78 def publish(*args) new(msg_args: args).publish end |
#setup ⇒ Cloudenvoy::Topic
Setup the default topic for this publisher.
87 88 89 90 91 |
# File 'lib/cloudenvoy/publisher.rb', line 87 def setup return nil unless default_topic PubSubClient.upsert_topic(default_topic) end |