Module: ValidateHTML::ActiveSupportNotificationHandler

Defined in:
lib/validate_html/active_support_notification_handler.rb

Overview

Validate HTML from Turbo::StreamsChannel as called by ActiveSupport::Notifications.instrument

Class Method Summary collapse

Class Method Details

.call(_name, _start, _finish, _id, payload) ⇒ Boolean

Validate HTML from Turbo::StreamsChannel as called by ActiveSupport::Notifications.instrument

Parameters:

  • payload (Hash)

    a customizable set of options

Options Hash (payload):

  • :channel_class (String)

    if this is Turbo::StreamsChannel the validation will happen

  • :data (String)

    the html to validate

Returns:

  • (Boolean)

    true if there are no validation errors

Raises:

See Also:



16
17
18
19
20
# File 'lib/validate_html/active_support_notification_handler.rb', line 16

def self.call(_name, _start, _finish, _id, payload)
  return unless payload && payload[:channel_class] == 'Turbo::StreamsChannel'

  ValidateHTML.validate_html(payload[:data])
end