Class: Messaging::Middleware::RailsWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/messaging/middleware/rails_wrapper.rb

Overview

Used for hot code reloading (in development) and connection handling. This makes Rails automatically return AR connections to the pool after we have used them when processing a messages.

See guides.rubyonrails.org/threading_and_code_execution.html for more information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RailsWrapper

Returns a new instance of RailsWrapper.



11
12
13
# File 'lib/messaging/middleware/rails_wrapper.rb', line 11

def initialize(app)
  self.app = app
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



9
10
11
# File 'lib/messaging/middleware/rails_wrapper.rb', line 9

def app
  @app
end

Instance Method Details

#call(*_args) ⇒ Object



15
16
17
18
19
# File 'lib/messaging/middleware/rails_wrapper.rb', line 15

def call(*_args)
  app.reloader.wrap do
    yield
  end
end