Sha256: e8924260e75da377b285f37d4269b391bdf0e0a54e49df9dbfa010a0e175ef9c
Contents?: true
Size: 762 Bytes
Versions: 9
Compression:
Stored size: 762 Bytes
Contents
# Handles interceptions during the lifecycle of a request # Represents all active interceptors for a request/response. class LHC::Interceptors attr_accessor :all # Intitalizes and determines if global or local interceptors are used def initialize(request) self.all = (request.options[:interceptors] || LHC.config.interceptors).map do |interceptor| interceptor.new(request) end end # Forwards messages to interceptors and handles provided responses. def intercept(name) all.each do |interceptor| result = interceptor.send(name) if result.is_a? LHC::Response fail 'Response already set from another interceptor' if @response @response = interceptor.request.response = result end end end end
Version data entries
9 entries across 9 versions & 1 rubygems