Extract ORM specifics

rework of PR #454

a good case <https://github.com/advancedcontrol/doorkeeper-couchbase>
Tested in https://github.com/doorkeeper-gem/doorkeeper/commit/680dc55f9e9ddd5f8bfca95f329ee57d51a3311f