Class: SearchKit::Messaging::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/search_kit/messaging.rb

Overview

Most of the logic for the Messaging module exists in this (not so) private class. This lets more complex handling of message logic enter into the module gracefully, for example silence or logging level.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Message

Returns a new instance of Message.



26
27
28
29
30
# File 'lib/search_kit/messaging.rb', line 26

def initialize(message)
  @env      = SearchKit.config.app_env.to_s.ansi(:magenta)
  @feedback = SearchKit.config.verbose
  @message  = message
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



24
25
26
# File 'lib/search_kit/messaging.rb', line 24

def env
  @env
end

#feedbackObject (readonly)

Returns the value of attribute feedback.



24
25
26
# File 'lib/search_kit/messaging.rb', line 24

def feedback
  @feedback
end

#messageObject (readonly)

Returns the value of attribute message.



24
25
26
# File 'lib/search_kit/messaging.rb', line 24

def message
  @message
end

Instance Method Details

#infoObject



37
38
39
40
# File 'lib/search_kit/messaging.rb', line 37

def info
  Kernel.puts("--> [ #{env} ]: #{message.ansi(:cyan)}") if feedback
  SearchKit.logger.info message
end

#warnObject



32
33
34
35
# File 'lib/search_kit/messaging.rb', line 32

def warn
  Kernel.warn("--> [ #{env} ]: #{message.ansi(:red)}") if feedback
  SearchKit.logger.warn message
end