Module: SyncMachine::OrmAdapters

Defined in:
lib/sync_machine/orm_adapters.rb,
lib/sync_machine/orm_adapters/mongoid_adapter.rb,
lib/sync_machine/orm_adapters/active_record_adapter.rb

Overview

Adapt generic SyncMachine functionality to a specific ORM.

Defined Under Namespace

Modules: ActiveRecordAdapter, MongoidAdapter

Class Method Summary collapse

Class Method Details

.orm_adapter(sync_module) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/sync_machine/orm_adapters.rb', line 4

def self.orm_adapter(sync_module)
  subject_class = sync_module.subject_class
  if const_defined?(:ActiveRecordAdapter) &&
     subject_class < ActiveRecord::Base
    ActiveRecordAdapter
  elsif const_defined?(:MongoidAdapter) &&
        subject_class.included_modules.include?(Mongoid::Document)
    MongoidAdapter
  end
end