Sha256: 008e6bbfa1bf2a3aff7b9c0c52b5c7d85d9b090bd39ca6ff50c7bd847e4955e2

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

module Underworld
  # A very simple class which provide functionalities to work with
  # current orm
  class ORM

    def self.active_record?
      current == 'active_record'
    end

    def self.mongoid?
      current == 'mongoid'
    end

    # current orm
    def self.current
      ::Underworld::Engine.orm.to_s
    end

    # This class method returns the base class of current ORM
    # It will be used in models to specify which class to inherit
    # from, based on current ORM
    def self.proper_base_class
      #TODO: fix this for rails 5 which has a new parent for each model
      return ::ActiveRecord::Base if active_record?
      return ::Object if mongoid?
      ::Underworld::Engine.orm = 'active_record'
      ::ActiveRecord::Base
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
underworld-1.0.0 lib/underworld/orm.rb