Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MatcherWrapper
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