Class: WhoopsLogger::MessageCreator
- Inherits:
-
Object
- Object
- WhoopsLogger::MessageCreator
- Defined in:
- lib/whoops_logger/message_creator.rb
Overview
A “glue” class which coordinates message creation
Instance Attribute Summary collapse
-
#message ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored.
-
#raw_data ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored.
-
#strategy ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored.
Instance Method Summary collapse
- #create! ⇒ Object
- #ignore_message? ⇒ Boolean
-
#initialize(strategy, raw_data) ⇒ MessageCreator
constructor
A new instance of MessageCreator.
Constructor Details
#initialize(strategy, raw_data) ⇒ MessageCreator
Returns a new instance of MessageCreator.
8 9 10 11 12 13 14 15 16 |
# File 'lib/whoops_logger/message_creator.rb', line 8 def initialize(strategy, raw_data) raise ArgumentError, "strategy can not be nil" if strategy.nil? raise ArgumentError, "strategy must respond to 'call'" unless strategy.respond_to?(:call) self.strategy = strategy self.raw_data = raw_data self. = Message.new self..event_time = Time.now self..logger_strategy_name = strategy.respond_to?(:name) ? strategy.name : 'anonymous' end |
Instance Attribute Details
#message ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored
6 7 8 |
# File 'lib/whoops_logger/message_creator.rb', line 6 def @message end |
#raw_data ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored
6 7 8 |
# File 'lib/whoops_logger/message_creator.rb', line 6 def raw_data @raw_data end |
#strategy ⇒ Object
get data from raw_data using a strategy to create a message and decide whether it should be ignored
6 7 8 |
# File 'lib/whoops_logger/message_creator.rb', line 6 def strategy @strategy end |
Instance Method Details
#create! ⇒ Object
18 19 20 |
# File 'lib/whoops_logger/message_creator.rb', line 18 def create! strategy.call(, raw_data) end |
#ignore_message? ⇒ Boolean
22 23 24 |
# File 'lib/whoops_logger/message_creator.rb', line 22 def .ignore? end |