Sha256: 53f968f26019dbe3519d748a251a1543c4e04ac916fc5bc95790080a280eea39

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 Bytes

Contents

Bundler.require(:default)

require "sync_machine/orm_adapters/active_record_adapter" if Module.const_defined?(:ActiveRecord)
require "sync_machine/orm_adapters/mongoid_adapter" if Module.const_defined?(:Mongoid)

module SyncMachine
  # Adapt generic SyncMachine functionality to a specific ORM.
  module OrmAdapters
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sync_machine-1.1.0 lib/sync_machine/orm_adapters.rb
sync_machine-1.0.0 lib/sync_machine/orm_adapters.rb