Class: Arel::Sql::Engine

Inherits:
Object
  • Object
show all
Includes:
CRUD
Defined in:
lib/arel/engines/sql/engine.rb

Defined Under Namespace

Modules: CRUD

Instance Method Summary collapse

Methods included from CRUD

#create, #delete, #read, #update

Constructor Details

#initialize(ar = nil) ⇒ Engine

Returns a new instance of Engine.



5
6
7
# File 'lib/arel/engines/sql/engine.rb', line 5

def initialize(ar = nil)
  @ar = ar
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



23
24
25
# File 'lib/arel/engines/sql/engine.rb', line 23

def method_missing(method, *args, &block)
  @ar.connection.send(method, *args, &block)
end

Instance Method Details

#adapter_nameObject



13
14
15
16
17
18
19
20
21
# File 'lib/arel/engines/sql/engine.rb', line 13

def adapter_name
  @adapter_name ||= case (name = connection.adapter_name)
  # map OracleEnanced adapter to Oracle
  when /Oracle/
    'Oracle'
  else
    name
  end
end

#connectionObject



9
10
11
# File 'lib/arel/engines/sql/engine.rb', line 9

def connection
  @ar ? @ar.connection : nil
end