Sha256: 2f9d7da80bac7d3eb4dd1374f0cbecd4c84ddca0463407969509d9e40ee8956a

Contents?: true

Size: 839 Bytes

Versions: 15

Compression:

Stored size: 839 Bytes

Contents

module Timber
  module Events
    # The template render event track template renderings and their performance.
    #
    # @note This event should be installed automatically through probes,
    #   such as the {Probes::ActionViewLogSubscriber} probe.
    class TemplateRender < Timber::Event
      attr_reader :message, :name, :time_ms

      def initialize(attributes)
        @message = attributes[:message] || raise(ArgumentError.new(":message is required"))
        @name = attributes[:name] || raise(ArgumentError.new(":name is required"))
        @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required"))
      end

      def to_hash
        {name: name, time_ms: time_ms}
      end
      alias to_h to_hash

      def as_json(_options = {})
        {:template_render => to_hash}
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
timber-1.0.13 lib/timber/events/template_render.rb
timber-1.0.12 lib/timber/events/template_render.rb
timber-1.0.11 lib/timber/events/template_render.rb
timber-1.0.10 lib/timber/events/template_render.rb
timber-1.0.9 lib/timber/events/template_render.rb
timber-1.0.8 lib/timber/events/template_render.rb
timber-1.0.7 lib/timber/events/template_render.rb
timber-1.0.6 lib/timber/events/template_render.rb
timber-1.0.5 lib/timber/events/template_render.rb
timber-1.0.4 lib/timber/events/template_render.rb
timber-1.0.3 lib/timber/events/template_render.rb
timberio-1.0.3 lib/timber/events/template_render.rb
timberio-1.0.2 lib/timber/events/template_render.rb
timberio-1.0.1 lib/timber/events/template_render.rb
timberio-1.0.0 lib/timber/events/template_render.rb