Class: Stashing
- Inherits:
-
Object
- Object
- Stashing
- Extended by:
- Forwardable
- Defined in:
- lib/stashing.rb,
lib/stashing/railtie.rb,
lib/stashing/version.rb,
lib/stashing/controller_ext.rb
Defined Under Namespace
Modules: ControllerExt Classes: Railtie
Constant Summary collapse
- STORE_KEY =
:stashing_data
- VERSION =
"0.1.3"
Class Attribute Summary collapse
-
.enable_cache_instrumentation ⇒ Object
Returns the value of attribute enable_cache_instrumentation.
Class Method Summary collapse
Class Attribute Details
.enable_cache_instrumentation ⇒ Object
Returns the value of attribute enable_cache_instrumentation.
8 9 10 |
# File 'lib/stashing.rb', line 8 def enable_cache_instrumentation @enable_cache_instrumentation end |
Class Method Details
.stash ⇒ Object
15 16 17 18 19 20 21 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 |