Class: Sapience::Extensions::Notifications
- Inherits:
-
Object
- Object
- Sapience::Extensions::Notifications
- Defined in:
- lib/sapience/extensions/notifications.rb
Direct Known Subclasses
ActionController::Notifications, ActiveJob::Notifications, ActiveRecord::Notifications, Grape::Notifications
Instance Attribute Summary collapse
-
#metric_name ⇒ Object
readonly
Returns the value of attribute metric_name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Notifications
constructor
A new instance of Notifications.
- #metrics ⇒ Object
- #record? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Notifications
Returns a new instance of Notifications.
27 28 29 |
# File 'lib/sapience/extensions/notifications.rb', line 27 def initialize( = {}) = [:tags] || [] end |
Instance Attribute Details
#metric_name ⇒ Object (readonly)
Returns the value of attribute metric_name.
11 12 13 |
# File 'lib/sapience/extensions/notifications.rb', line 11 def metric_name @metric_name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
11 12 13 |
# File 'lib/sapience/extensions/notifications.rb', line 11 def end |
Class Method Details
.subscribe(pattern, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/sapience/extensions/notifications.rb', line 17 def self.subscribe(pattern, &block) if defined?(ActiveSupport::Notifications) ::ActiveSupport::Notifications.subscribe(pattern) do |*args| block.call ::ActiveSupport::Notifications::Event.new(*args) end else warn "ActiveSupport not available" end end |
.use(options = {}) ⇒ Object
13 14 15 |
# File 'lib/sapience/extensions/notifications.rb', line 13 def self.use( = {}) new() end |
Instance Method Details
#metrics ⇒ Object
35 36 37 |
# File 'lib/sapience/extensions/notifications.rb', line 35 def metrics Sapience.metrics end |
#record? ⇒ Boolean
31 32 33 |
# File 'lib/sapience/extensions/notifications.rb', line 31 def record? !metrics.nil? end |