-
-
Save kristofers91/f49ae670cbdf1fb81e779b565d8bdabd to your computer and use it in GitHub Desktop.
This file contains 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 SlackResource | |
def self.build | |
new | |
end | |
def send_message | |
puts("Sending slack message") | |
end | |
end | |
class ClassA | |
def self.build | |
new(Notification.build) | |
end | |
def initialize(notification) | |
self.notification = notification | |
end | |
def call(message) | |
notification.call(message) | |
end | |
end | |
class ClassB < ClassA | |
end | |
class ClassB | |
class Notification | |
def self.build | |
new(SlackResource.build) | |
end | |
def initialize(slack_resource) | |
self.slack_resource = slack_resource | |
end | |
def call(message) | |
notify_slack(message) | |
end | |
end | |
end | |
ClassB::Notification.build.call("my message") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment