Skip to content

Instantly share code, notes, and snippets.

@waterlink
Created January 28, 2015 02:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save waterlink/8afa40f0c869b6953f06 to your computer and use it in GitHub Desktop.
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