Method: Needle::Container#intercept

Defined in:
lib/needle/container.rb

#intercept(name) ⇒ Object

Describe a new interceptor to use that will intercept method calls on the named service. This method returns a new Interceptor instance, which can be used directly to configure the behavior of the interceptor.

Usage:

container.intercept( :calc ).with { |c| c.logging_interceptor }

Raises:



261
262
263
264
265
266
267
268
269
# File 'lib/needle/container.rb', line 261

def intercept( name )
  point = find_definition( name )
  raise ServiceNotFound, "#{fullname}.#{name}" unless point

  interceptor = self[ :interceptor_impl_factory ].new
  point.interceptor interceptor

  interceptor
end