module Cloudenvoy::Publisher::ClassMethods

Module class methods

Public Instance Methods

cloudenvoy_options(opts = {}) click to toggle source

Set the publisher runtime options.

@param [Hash] opts The publisher options.

@return [Hash] The options set.

# File lib/cloudenvoy/publisher.rb, line 47
def cloudenvoy_options(opts = {})
  opt_list = opts&.map { |k, v| [k.to_sym, v] } || [] # symbolize
  @cloudenvoy_options_hash = Hash[opt_list]
end
cloudenvoy_options_hash() click to toggle source

Return the publisher runtime options.

@return [Hash] The publisher runtime options.

# File lib/cloudenvoy/publisher.rb, line 57
def cloudenvoy_options_hash
  @cloudenvoy_options_hash || {}
end
default_topic() click to toggle source

Return the default topic this publisher publishes to. Raises an error if no default topic has been defined.

@return [String] The default topic.

# File lib/cloudenvoy/publisher.rb, line 67
def default_topic
  cloudenvoy_options_hash[:topic]
end
publish(*args) click to toggle source

Format and publish objects to Pub/Sub.

@param [Any] *args The publisher arguments

@return [Cloudenvoy::Message] The created message.

# File lib/cloudenvoy/publisher.rb, line 78
def publish(*args)
  new(msg_args: args).publish
end
setup() click to toggle source

Setup the default topic for this publisher.

@return [Cloudenvoy::Topic] The upserted/topic.

# File lib/cloudenvoy/publisher.rb, line 87
def setup
  return nil unless default_topic

  PubSubClient.upsert_topic(default_topic)
end