Sha256: b7610b70f0d087be2ea6f9b64c83b592249fee37623d544cf693992f91cdda20
Contents?: true
Size: 900 Bytes
Versions: 10
Compression:
Stored size: 900 Bytes
Contents
# Handles interceptions during the lifecycle of a request class LHC::InterceptorProcessor attr_accessor :interceptors # Intitalizes the processor and determines if global or local interceptors are used def initialize(target) options = target.options if target.is_a? LHC::Request options ||= target.request.options if target.is_a? LHC::Response self.interceptors = (options[:interceptors] || LHC.config.interceptors).map{ |i| i.new } end # Forwards messages to interceptors and handles provided responses. def intercept(name, target) interceptors.each do |interceptor| result = interceptor.send(name, target) if result.is_a? LHC::Response fail 'Response already set from another interceptor' if @response request = target.is_a?(LHC::Request) ? target : target.request @response = request.response = result end end end end
Version data entries
10 entries across 10 versions & 1 rubygems