Created
September 16, 2017 15:01
-
-
Save kopylovvlad/5311bab442982856f71593a08326c297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlackLogger | |
def initialize(message) | |
@message = message | |
end | |
def sending | |
puts 'we sending message to Slack' | |
end | |
end | |
class EmailLogger | |
def initialize(message) | |
@message = message | |
end | |
def sending | |
puts 'we sending message to Email' | |
end | |
end | |
class StorageLogger | |
def initialize(message) | |
@message = message | |
end | |
def sending | |
puts 'we sending message to some storage' | |
end | |
end | |
class AbstractLogging | |
attr_reader :log_string, :logger_factory | |
def initialize(log_string, logger_factory = nil) | |
@log_string = log_string | |
@logger_factory = logger_factory | |
end | |
def action | |
raise 'logger_factory is not implemented' if logger_factory.nil? | |
logger_factory.new(log_string).sending | |
end | |
end | |
AbstractLogging.new('some error', SlackLogger).action | |
AbstractLogging.new('some error', EmailLogger).action | |
AbstractLogging.new('some error', StorageLogger).action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment