Sha256: cda62e69555a0700f7e6619a7f0dcf676ffe490f26254fd5c7c8727729a7ec4a

Contents?: true

Size: 788 Bytes

Versions: 3

Compression:

Stored size: 788 Bytes

Contents

class Rack::Tracker::Handler
  class_attribute :position
  self.position = :head

  attr_accessor :options
  attr_accessor :env

  # Allow javascript escaping in view templates
  include Rack::Tracker::JavaScriptHelper

  def initialize(env, options = {})
    self.env = env
    self.options  = options
    self.position = options[:position] if options.has_key?(:position)
  end

  def events
    events = env.fetch('tracker', {})[self.class.to_s.demodulize.underscore] || []
    events.map{ |ev| "#{self.class}::#{ev['class_name']}".constantize.new(ev.except('class_name')) }
  end

  def render
    raise NotImplementedError.new('needs implementation')
  end

  def self.track(name, event)
    raise NotImplementedError.new("class method `#{__callee__}` is not implemented.")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-tracker-1.2.0 lib/rack/tracker/handler.rb
rack-tracker-1.1.0 lib/rack/tracker/handler.rb
rack-tracker-1.0.2 lib/rack/tracker/handler.rb