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

+ (Boolean) active_record?

Returns:

  • (Boolean)


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

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

+ (Object) current

current orm



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

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

+ (Boolean) mongoid?

Returns:

  • (Boolean)


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

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

+ (Object) proper_base_class

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
# File 'lib/faalis/orm.rb', line 22

def self.proper_base_class
  return ActiveRecord::Base if active_record?
  return Object if mongoid?
  Faalis::Engine.orm = 'active_record'
  ActiveRecord::Base
end