Class: Carnivore::Source::Spec

Inherits:
Carnivore::Source show all
Defined in:
lib/carnivore/spec_helper.rb

Overview

Dummy source for testing used to capture payloads for inspection

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Spec) initialize(*args) { ... }

Creates new spec source

Parameters:

  • args (Object)

    argument list (passed to Source)

Yields:

  • source block (passed to Source)



71
72
73
74
# File 'lib/carnivore/spec_helper.rb', line 71

def initialize(*args, &block)
  super
  @confirmed = []
end

Instance Attribute Details

- (TrueClass, FalseClass) auto_confirm (readonly) Originally defined in class Carnivore::Source

Returns auto confirm received messages

Returns:

  • (TrueClass, FalseClass)

    auto confirm received messages

- (TrueClass, FalseClass) auto_process (readonly) Originally defined in class Carnivore::Source

Returns start source processing on initialization

Returns:

  • (TrueClass, FalseClass)

    start source processing on initialization

- (Carnivore::Supervisor) callback_supervisor (readonly) Originally defined in class Carnivore::Source

Returns supervisor maintaining callback instances

Returns:

- (Array<Callback>) callbacks (readonly) Originally defined in class Carnivore::Source

Returns registered callbacks

Returns:

  • (Array<Callback>)

    registered callbacks

- (Array) confirmed (readonly)

Returns messages confirmed

Returns:

  • (Array)

    messages confirmed



65
66
67
# File 'lib/carnivore/spec_helper.rb', line 65

def confirmed
  @confirmed
end

- (Queue) message_loop (readonly) Originally defined in class Carnivore::Source

Returns local loop message queue

Returns:

  • (Queue)

    local loop message queue

- (Hash) message_registry (readonly) Originally defined in class Carnivore::Source

Returns registry of processed messages

Returns:

  • (Hash)

    registry of processed messages

- (Queue) message_remote (readonly) Originally defined in class Carnivore::Source

Returns remote message queue

Returns:

  • (Queue)

    remote message queue

- (String, Symbol) name (readonly) Originally defined in class Carnivore::Source

Returns name of source

Returns:

  • (String, Symbol)

    name of source

- (TrueClass, FalseClass) processing (readonly) Originally defined in class Carnivore::Source

Returns currently processing a message

Returns:

  • (TrueClass, FalseClass)

    currently processing a message

- (TrueClass, FalseClass) run_process (readonly) Originally defined in class Carnivore::Source

Returns message processing control switch

Returns:

  • (TrueClass, FalseClass)

    message processing control switch

Instance Method Details

- (TrueClass) confirm(payload, *args)

Capture confirmed messages

Parameters:

  • payload (Object)

    payload of message

  • args (Object)

    argument list (unused)

Returns:

  • (TrueClass)


113
114
115
116
# File 'lib/carnivore/spec_helper.rb', line 113

def confirm(payload, *args)
  confirmed << payload
  true
end

- (Carnivore::Message) format(msg)

Format the message

Parameters:

  • msg (Object)

    message payload

Returns:



101
102
103
104
105
106
# File 'lib/carnivore/spec_helper.rb', line 101

def format(msg)
  Message.new(
    :message => msg,
    :source => self
  )
end

- (Object) receive(*args)

Dummy receiver



84
85
86
# File 'lib/carnivore/spec_helper.rb', line 84

def receive(*args)
  wait(:forever)
end

- (Array) setup(*args)

Setup the message store for payload storage

Returns:

  • (Array)

    message storage



79
80
81
# File 'lib/carnivore/spec_helper.rb', line 79

def setup(*args)
  MessageStore.init
end

- (TrueClass) transmit(*args)

Capture messages transmitted

Parameters:

  • args (Object)

    argument list

Returns:

  • (TrueClass)


92
93
94
95
# File 'lib/carnivore/spec_helper.rb', line 92

def transmit(*args)
  MessageStore.messages << args.first
  true
end