Class: ActiveRecord::StructuredEventSubscriber
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveSupport::StructuredEventSubscriber
|
Defined in: | activerecord/lib/active_record/structured_event_subscriber.rb |
Constant Summary
-
IGNORE_PAYLOAD_NAMES =
# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 7["SCHEMA", "EXPLAIN"]
::ActiveSupport::StructuredEventSubscriber
- Inherited
Class Attribute Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
Class Method Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
.attach_to | Attach the subscriber to a namespace. |
.detach_from | Detach the subscriber from a namespace. |
.method_added | Adds event subscribers for all new methods added to the class. |
.new, .subscribers, .add_event_subscriber, .fetch_public_methods, .find_attached_subscriber, .invalid_event?, .pattern_subscribed?, .prepare_pattern, .remove_event_subscriber |
Instance Attribute Summary
::ActiveSupport::StructuredEventSubscriber
- Inherited
::ActiveSupport::Subscriber
- Inherited
Instance Method Summary
- #sql(event)
- #strict_loading_violation(event)
- #filter(name, value) private
- #render_bind(attr, value) private
- #type_casted_binds(casted_binds) private
::ActiveSupport::StructuredEventSubscriber
- Inherited
#call, | |
#emit_debug_event | Like |
#emit_event | Emit a structured event via Rails.event.notify. |
#silenced?, #handle_event_error |
::ActiveSupport::Subscriber
- Inherited
Constructor Details
This class inherits a constructor from ActiveSupport::StructuredEventSubscriber
Instance Method Details
#filter(name, value) (private)
[ GitHub ]# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 78
def filter(name, value) ActiveRecord::Base.inspection_filter.filter_param(name, value) end
#render_bind(attr, value) (private)
[ GitHub ]# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 63
def render_bind(attr, value) case attr when ActiveModel::Attribute if attr.type.binary? && attr.value value = "<#{attr.value_for_database.to_s.bytesize} bytes of binary data>" end when Array attr = attr.first else attr = nil end [attr&.name, value] end
#sql(event)
[ GitHub ]# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 21
def sql(event) payload = event.payload return if IGNORE_PAYLOAD_NAMES.include?(payload[:name]) binds = nil if payload[:binds]&.any? casted_params = type_casted_binds(payload[:type_casted_binds]) binds = [] payload[:binds].each_with_index do |attr, i| attribute_name = if attr.respond_to?(:name) attr.name elsif attr.respond_to?(:[]) && attr[i].respond_to?(:name) attr[i].name else nil end filtered_params = filter(attribute_name, casted_params[i]) binds << render_bind(attr, filtered_params) end end emit_debug_event("active_record.sql", async: payload[:async], name: payload[:name], sql: payload[:sql], cached: payload[:cached], lock_wait: payload[:lock_wait], binds: binds, ) end
#strict_loading_violation(event)
[ GitHub ]# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 9
def strict_loading_violation(event) owner = event.payload[:owner] reflection = event.payload[:reflection] emit_debug_event("active_record.strict_loading_violation", owner: owner.name, class: reflection.klass.name, name: reflection.name, ) end
#type_casted_binds(casted_binds) (private)
[ GitHub ]# File 'activerecord/lib/active_record/structured_event_subscriber.rb', line 59
def type_casted_binds(casted_binds) casted_binds.respond_to?(:call) ? casted_binds.call : casted_binds end