Sha256: 2c0ff27439da3a8a881fd13b2d41715472ce13e2d8eed501340d32b5a1b22a0f
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
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 inject(response) # Sub! is enough, in well formed html there's only one head or body tag. # Block syntax need to be used, otherwise backslashes in input will mess the output. # @see http://stackoverflow.com/a/4149087/518204 and https://github.com/railslove/rack-tracker/issues/50 response.sub! %r{</#{self.position}>} do |m| self.render << m.to_s end response end def self.track(name, event) raise NotImplementedError.new("class method `#{__callee__}` is not implemented.") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rack-tracker-1.3.1 | lib/rack/tracker/handler.rb |
rack-tracker-1.3.0 | lib/rack/tracker/handler.rb |