Sha256: 97ac327c22e15d8489b67f2c3685212837ab7a01c8b4bb6f15cae86162149cb9

Contents?: true

Size: 855 Bytes

Versions: 2

Compression:

Stored size: 855 Bytes

Contents

require 'tracebin/helpers'

module Tracebin
  class Event
    include Tracebin::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

2 entries across 2 versions & 1 rubygems

Version Path
tracebin-0.0.9 lib/tracebin/events.rb
tracebin-0.0.8 lib/tracebin/events.rb