Extract ORM specifics

rework of PR #454

a good case <https://github.com/advancedcontrol/doorkeeper-couchbase>
`instance_of` does what we want though, see http://stackoverflow.com/a/3893305/356060.