Prefer duck typing to type matching

The previous fix for Rails 3.1 broke compatibility with non-ActiveRecord
projects. This fixes #90 and #94.