class Flor::Journal

A Journal hook, receives only “consumed” messages and keeps a copy of all of them.

Used in specs, do not uses as-is in production, since it simply grows in memory…

Attributes

messages[R]

Public Class Methods

new(unit) click to toggle source
# File lib/flor/unit/journal.rb, line 15
def initialize(unit)

  # Add a #journal method to the flor unit so that
  # `unit.journal` yields the message list.
  #
  unit.singleton_class.instance_eval do

    define_method(:journal) do
      @hooker['journal'].messages
    end
  end

  @messages = []
end

Public Instance Methods

notify(executor, message) click to toggle source

The method used by the hooker to give consumed messages to this journal

# File lib/flor/unit/journal.rb, line 43
def notify(executor, message)

  @messages << Flor.dup(message)
    # stores a deep clone of each consumed message

  [] # no new messages
end
opts() click to toggle source

Tells the hooker that this hook is only interested in message that have been “consumed”, remember, the hooker passes messages to hooks before consumption and after consumption. In this case only consumed messages are passed.

Other hooks may declare they are only interested in messages belonging to a certain domain or having a certain tag. See spec/unit/unit_hooks_spec.rb for more filtering examples.

# File lib/flor/unit/journal.rb, line 39
def opts; { consumed: true }; end