Class: ActiveRecord::Acts::List::WithConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_list/active_record/acts/with_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipient) ⇒ WithConnection

Returns a new instance of WithConnection.



7
8
9
# File 'lib/acts_as_list/active_record/acts/with_connection.rb', line 7

def initialize(recipient)
  @recipient = recipient
end

Instance Attribute Details

#recipientObject (readonly)

Returns the value of attribute recipient.



11
12
13
# File 'lib/acts_as_list/active_record/acts/with_connection.rb', line 11

def recipient
  @recipient
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
# File 'lib/acts_as_list/active_record/acts/with_connection.rb', line 13

def call
  if recipient.respond_to?(:with_connection)
    recipient.with_connection do |connection|
      yield connection
    end
  else
    yield recipient.connection
  end
end