-
-
Save samuel02/64867c98df47a14da172 to your computer and use it in GitHub Desktop.
inheritance with blocks
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 A | |
def initialize | |
@logger = Rails.logger || Logger.new(STDOUT) | |
end | |
def foo | |
begin | |
yield | |
rescue StandardError => e | |
@logger.error e | |
raise StandardError | |
end | |
end | |
end | |
class B < A | |
def foo | |
super do | |
f = File.open('baz.txt', 'w') | |
f.write('lorem') | |
f.close | |
end | |
end | |
end | |
class C < A | |
def foo | |
super do | |
... | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment