Class: Informed::Informant::Message
- Inherits:
-
Object
- Object
- Informed::Informant::Message
- Defined in:
- lib/informed.rb
Overview
Standard message that is logged when informed upon methods are executed.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#also_log ⇒ Hash
From #also_log.
-
#informee ⇒ Object
From #inform_on.
-
#keyword_arguments ⇒ Hash
From #inform_on.
-
#method ⇒ Symbol
From #method.
Instance Method Summary collapse
-
#initialize(method:, keyword_arguments:, informee:, also_log:) ⇒ Message
constructor
A new instance of Message.
-
#to_h ⇒ Hash
The message for the informant to log, in hash form.
Constructor Details
#initialize(method:, keyword_arguments:, informee:, also_log:) ⇒ Message
Returns a new instance of Message.
185 186 187 188 189 190 |
# File 'lib/informed.rb', line 185 def initialize(method:, keyword_arguments:, informee:, also_log:) self.keyword_arguments = keyword_arguments self.informee = informee self.also_log = also_log self.method = method end |
Instance Attribute Details
#also_log ⇒ Hash
Returns from Informed::Informant#also_log.
181 182 183 |
# File 'lib/informed.rb', line 181 def also_log @also_log end |
#informee ⇒ Object
Returns from Informed::Informant#inform_on.
178 179 180 |
# File 'lib/informed.rb', line 178 def informee @informee end |
#keyword_arguments ⇒ Hash
Returns from Informed::Informant#inform_on.
175 176 177 |
# File 'lib/informed.rb', line 175 def keyword_arguments @keyword_arguments end |
#method ⇒ Symbol
Returns from Informed::Informant#method.
184 185 186 |
# File 'lib/informed.rb', line 184 def method @method end |
Instance Method Details
#to_h ⇒ Hash
The message for the informant to log, in hash form. Actual return value depends on #also_log
195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/informed.rb', line 195 def to_h = { method: method, class: informee.class.name } if also_log[:values] [:values] = {} also_log[:values].each do |local| [:values][local] ||= keyword_arguments[local] if keyword_arguments.key?(local) [:values][local] ||= informee.send(local) if informee.respond_to?(local, true) end end end |