= ActiveSupport::Subscriber < Object (from /home/chedong/.local/share/rdoc) ------------------------------------------------------------------------ ActiveSupport::Subscriber is an object set to consume ActiveSupport::Notifications. The subscriber dispatches notifications to a registered object based on its given namespace. An example would be an Active Record subscriber responsible for collecting statistics about queries: module ActiveRecord class StatsSubscriber < ActiveSupport::Subscriber attach_to :active_record def sql(event) Statsd.timing("sql.#{event.payload[:name]}", event.duration) end end end After configured, whenever a "sql.active_record" notification is published, it will properly dispatch the event (ActiveSupport::Notifications::Event) to the sql method. We can detach a subscriber as well: ActiveRecord::StatsSubscriber.detach_from(:active_record) ------------------------------------------------------------------------ = Class methods: add_event_subscriber attach_to detach_from method_added new remove_event_subscriber subscribers = Instance methods: finish start
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-29 18:38 @216.73.216.177
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)