Class: Informed::Informant::DoneMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/informed.rb

Overview

Message that’s logged when an informed upon method is completed

Instance Attribute Summary collapse

Attributes inherited from Message

#also_log, #informee, #keyword_arguments, #method

Instance Method Summary collapse

Constructor Details

#initialize(result:, **kwargs) ⇒ DoneMessage

Returns a new instance of DoneMessage.

Parameters:

  • result (Object)

    Result of the called method. may be logged if Message#also_log has ‘result: true`

See Also:



224
225
226
227
# File 'lib/informed.rb', line 224

def initialize(result:, **kwargs)
  super(**kwargs)
  self.result = result
end

Instance Attribute Details

#resultObject

Returns the value of attribute result.



219
220
221
# File 'lib/informed.rb', line 219

def result
  @result
end

Instance Method Details

#to_hHash

Returns a Hash with ‘status: :done` and the result of Informed::Informant#message.

Returns:

  • (Hash)

    a Hash with ‘status: :done` and the result of Informed::Informant#message



230
231
232
233
234
# File 'lib/informed.rb', line 230

def to_h
  done_message = { status: :done }
  done_message[:result] = result if also_log[:result]
  super.merge(done_message)
end