class Stashing
Constants
- STORE_KEY
- VERSION
Attributes
enable_cache_instrumentation[RW]
Public Class Methods
stash()
click to toggle source
# File lib/stashing.rb, line 15 def self.stash if RequestStore.store[STORE_KEY].nil? # Get each event_store it's own private Hash instance. RequestStore.store[STORE_KEY] = Hash.new { |hash, key| hash[key] = {} } end RequestStore.store[STORE_KEY] end
watch(event, opts = {}, &block)
click to toggle source
# File lib/stashing.rb, line 23 def self.watch(event, opts = {}, &block) event_group = opts[:event_group] || event ActiveSupport::Notifications.subscribe(event) do |*args| begin # It's necessary to add the custom_fields at runtime, otherwise LogStasher overrides them. Stashing.custom_fields << event_group unless Stashing.custom_fields.include? event_group # Calling the processing block with the Notification args, plus the event_stash block.call(*args, stash[event_group]) rescue StandardError end end end