Sha256: cca9b0df2e291f4c2c199ef79f88c0134a62a88d534881cd108e7b2c1ad56534

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

require 'vizsla/helpers'

module Vizsla
  class Event
    include Vizsla::Helpers

    attr_reader :event

    def initialize(event)
      @event = event
    end

    def recorder_type
      event[0]
    end

    def valid?
      true
    end

    def data_hash
      {
        event_type: type,
        start: event[1],
        stop: event[2],
        duration: to_milliseconds(event[2] - event[1]),
        data: event.last
      }
    end
  end

  class SQLEvent < Event
    def valid?
      event.last[:name] != "SCHEMA"
    end

    private

    def type
      :sql
    end
  end

  class ControllerEvent < Event
    private

    def type
      :controller_action
    end
  end

  class ViewEvent < Event
    private

    def type
      :view
    end
  end

  class SinatraEvent < Event
    private

    def type
      :route
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.7 lib/vizsla/events.rb