Created
January 28, 2015 02:21
-
-
Save waterlink/8afa40f0c869b6953f06 to your computer and use it in GitHub Desktop.
MatcherWrapper
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 MatcherWrapper | |
def initialize(matcher) | |
@matcher = matcher | |
end | |
def diffable? | |
with_default(false) { @matcher.diffable? } | |
end | |
def description | |
with_default(matcher.inspect) { @matcher.description } | |
end | |
# ... and all other optional matcher protocol methods ... | |
private | |
def with_default(default) | |
yield | |
rescue NoMethodError | |
default | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment