Skip to content

Instantly share code, notes, and snippets.

@kristofers91
Last active July 9, 2018 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristofers91/f49ae670cbdf1fb81e779b565d8bdabd to your computer and use it in GitHub Desktop.
Save kristofers91/f49ae670cbdf1fb81e779b565d8bdabd to your computer and use it in GitHub Desktop.
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