Class: Promiscuous::Publisher::Context::Base
- Inherits:
-
Object
- Object
- Promiscuous::Publisher::Context::Base
- Defined in:
- lib/promiscuous/publisher/context/base.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
Class Method Summary collapse
-
.current ⇒ Object
XXX Context are not sharable among threads.
Instance Method Summary collapse
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
8 9 10 |
# File 'lib/promiscuous/publisher/context/base.rb', line 8 def current_user @current_user end |
Class Method Details
.current ⇒ Object
XXX Context are not sharable among threads
4 5 6 |
# File 'lib/promiscuous/publisher/context/base.rb', line 4 def self.current Thread.current[:promiscuous_context] ||= self.new end |
Instance Method Details
#trace(msg, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/promiscuous/publisher/context/base.rb', line 15 def trace(msg, ={}) level = ENV['TRACE'].to_i - [:level].to_i return if level < 0 backtrace = [:backtrace] alt_fmt = [:alt_fmt] color = [:color] || "1;36" name = " (#{self.name})#{' ' * ([0, 25 - self.name.size].max)}" STDERR.puts "\e[#{color}m#{name}#{alt_fmt ? '':' '} #{msg}\e[0m" if level > 1 && defined?(Rails) && backtrace != :none bt = (backtrace || caller) .grep(/#{Rails.root}/) .map { |line| line.gsub(/#{Rails.root}\/?/, '') } .take(level-1) .map { |line| "\e[1;#{30}m#{name} #{line}\e[0m" } .join("\n") STDERR.puts bt end end |
#transaction_context_of(driver) ⇒ Object
10 11 12 13 |
# File 'lib/promiscuous/publisher/context/base.rb', line 10 def transaction_context_of(driver) @transaction_managers ||= {} @transaction_managers[driver] ||= Promiscuous::Publisher::Context::Transaction.new(driver) end |