Module: BunnyPublisher

Defined in:
lib/bunny_publisher.rb,
lib/bunny_publisher/base.rb,
lib/bunny_publisher/test.rb,
lib/bunny_publisher/errors.rb,
lib/bunny_publisher/version.rb,
lib/bunny_publisher/callbacks.rb,
lib/bunny_publisher/mandatory.rb

Defined Under Namespace

Modules: Callbacks, Mandatory, Test Classes: Base, CannotCreateQueue, ReturnedMessageError

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.configure {|config| ... } ⇒ Object

Yields:

  • (config)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bunny_publisher.rb', line 24

def configure
  require 'ostruct'

  config = OpenStruct.new(mandatory: false, test: false)

  yield(config)

  klass = Class.new(Base) do
    include ::BunnyPublisher::Mandatory if config.delete_field(:mandatory)
    include ::BunnyPublisher::Test      if config.delete_field(:test)
  end

  @publisher = klass.new(**config.to_h)
end

.method_missing(method_name, *args) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/bunny_publisher.rb', line 39

def method_missing(method_name, *args)
  if publisher.respond_to?(method_name)
    publisher.send(method_name, *args)
  else
    super
  end
end

.publish(message, options = {}) ⇒ Object



16
17
18
# File 'lib/bunny_publisher.rb', line 16

def publish(message, options = {})
  publisher.publish(message, options)
end

.publisherObject



20
21
22
# File 'lib/bunny_publisher.rb', line 20

def publisher
  @publisher ||= Base.new
end

.respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/bunny_publisher.rb', line 47

def respond_to_missing?(method_name, *args)
  publisher.respond_to?(method_name) || super
end