Class: ActiveRecord::ConnectionAdapters::ConnectionManagement::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/connection_pool.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, testing = false) ⇒ Proxy

Returns a new instance of Proxy.



446
447
448
449
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 446

def initialize(body, testing = false)
  @body    = body
  @testing = testing
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



451
452
453
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 451

def method_missing(method_sym, *arguments, &block)
  @body.send(method_sym, *arguments, &block)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



444
445
446
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 444

def body
  @body
end

#testingObject (readonly)

Returns the value of attribute testing.



444
445
446
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 444

def testing
  @testing
end

Instance Method Details

#closeObject



463
464
465
466
467
468
469
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 463

def close
  body.close if body.respond_to?(:close)

  # Don't return connection (and perform implicit rollback) if
  # this request is a part of integration test
  ActiveRecord::Base.clear_active_connections! unless testing
end

#each(&block) ⇒ Object



459
460
461
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 459

def each(&block)
  body.each(&block)
end

#respond_to?(method_sym, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


455
456
457
# File 'lib/active_record/connection_adapters/abstract/connection_pool.rb', line 455

def respond_to?(method_sym, include_private = false)
  super || @body.respond_to?(method_sym)
end