Module: Clustr::Message

Defined in:
lib/clustr.rb

Overview

Provides classes with the ability to store messages for consumption elsewhere within the application. Typically via the CLI.

Examples:

Including and using the Message module.

class Foo
  include Clustr::Message
  def initialize
    message "The class has been initialized!", :type => :ok
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#message_procObject (readonly)

Returns the value of attribute message_proc.



33
34
35
# File 'lib/clustr.rb', line 33

def message_proc
  @message_proc
end

Instance Method Details

#message_handler(&message_proc) ⇒ Object

Binds a message handler to proc a block when a message is added to the messages array.

Parameters:

  • message_proc (Proc)

    the block to call when a message is added.



39
40
41
# File 'lib/clustr.rb', line 39

def message_handler(&message_proc)
  @message_proc = message_proc
end