/respond_to

Easy way to make respond_to? matchers for case statements.

Primary LanguageRuby

respond_to

Easy way to make respond_to? matchers for case statements.

Usage

require 'respond_to'
str = 'my string'
case str
when ~:<<
  str << 'new data'
when ~:push
  str.push 'new data'
when ~:+
  str += 'new data'
else
  raise
end