Class: DataMapper::MasterSlaveAdapter::Middleware::WriteUnbinding

Inherits:
Object
  • Object
show all
Defined in:
lib/data_mapper/master_slave_adapter/middleware/write_unbinding.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, name = :default) ⇒ WriteUnbinding

Returns a new instance of WriteUnbinding.



15
16
17
18
# File 'lib/data_mapper/master_slave_adapter/middleware/write_unbinding.rb', line 15

def initialize(app, name = :default)
  @app  = app
  @name = name.to_sym
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
# File 'lib/data_mapper/master_slave_adapter/middleware/write_unbinding.rb', line 20

def call(env)
  @app.call(env)
ensure
  adapter = DataMapper.repository(@name).adapter
  adapter.reset_binding if adapter.respond_to?(:reset_binding)
end