added catpure method.
it was taken directly from active support to reduce the dependencies of
your gem. license of code is
https://github.com/rails/rails/blob/master/activesupport/MIT-LICENSE