Class: Faalis::ORM

Inherits:
Object
  • Object
show all
Defined in:
lib/faalis/orm.rb

Overview

A very simple class which provide functionalities to work with current orm

Class Method Summary collapse

Class Method Details

.active_record?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/faalis/orm.rb', line 6

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

.currentObject

current orm



15
16
17
# File 'lib/faalis/orm.rb', line 15

def self.current
  ::Faalis::Engine.orm.to_s
end

.mongoid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/faalis/orm.rb', line 10

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

.proper_base_classObject

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



22
23
24
25
26
27
28
# File 'lib/faalis/orm.rb', line 22

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?
  ::Faalis::Engine.orm = 'active_record'
  ::ActiveRecord::Base
end