Skip to content

Instantly share code, notes, and snippets.

@waterlink
Created January 28, 2015 02:21
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 waterlink/8afa40f0c869b6953f06 to your computer and use it in GitHub Desktop.
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