Module: Logidze::Responsible
- Included in:
- Logidze
- Defined in:
- lib/logidze/responsible.rb
Overview
Provide methods to work with “responsibility” feature
Instance Method Summary collapse
Instance Method Details
#with_responsible(responsible_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/logidze/responsible.rb', line 5 def with_responsible(responsible_id) return yield if responsible_id.nil? ActiveRecord::Base.transaction do ActiveRecord::Base.connection.execute( "SET LOCAL logidze.responsible = #{ActiveRecord::Base.connection.quote(responsible_id)};" ) res = yield ActiveRecord::Base.connection.execute "SET LOCAL logidze.responsible TO DEFAULT;" res end end |