Class: Arel::Session

Inherits:
Object
  • Object
show all
Includes:
CRUD
Defined in:
lib/arel/session.rb

Defined Under Namespace

Modules: CRUD

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from CRUD

#create, #delete, #read, #update

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



4
5
6
# File 'lib/arel/session.rb', line 4

def instance
  @instance
end

Class Method Details

.startObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/arel/session.rb', line 7

def start
  if defined?(@started) && @started
    yield
  else
    begin
      @started = true
      @instance = manufacture
      singleton_class.class_eval do
        undef :new
        alias_method :new, :instance
      end
      yield
    ensure
      singleton_class.class_eval do
        undef :new
        alias_method :new, :manufacture
      end
      @started = false
    end
  end
end