Sha256: 24894d3780635963d76cb376d9caeee3ef6c1c6cf7ea58d5f8f8eca683c857a0

Contents?: true

Size: 481 Bytes

Versions: 15

Compression:

Stored size: 481 Bytes

Contents

module Spank
  class InterceptorRegistration
    def initialize(method_symbol)
      @method = method_symbol
      @interceptors = []
    end

    def with(interceptor)
      @interceptors.push(interceptor)
      self
    end

    def and(interceptor)
      with(interceptor)
    end

    def intercept(instance)
      proxy = Proxy.new(instance)
      @interceptors.each do |interceptor|
        proxy.add_interceptor(@method, interceptor)
      end
      proxy
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spank-1.1.0 lib/spank/interceptor_registration.rb
spank-1.0.1441140881 lib/spank/interceptor_registration.rb
spank-1.0.1441140857 lib/spank/interceptor_registration.rb
spank-1.0.1441140848 lib/spank/interceptor_registration.rb
spank-1.0.1441140841 lib/spank/interceptor_registration.rb
spank-1.0.1441140834 lib/spank/interceptor_registration.rb
spank-1.0.1441140824 lib/spank/interceptor_registration.rb
spank-1.0.1441140809 lib/spank/interceptor_registration.rb
spank-1.0.1441140804 lib/spank/interceptor_registration.rb
spank-1.0.1441140793 lib/spank/interceptor_registration.rb
spank-1.0.1420314444 lib/spank/interceptor_registration.rb
spank-0.0.1393558686 lib/spank/interceptor_registration.rb
spank-0.0.1385937112 lib/spank/interceptor_registration.rb
spank-0.0.1369197619 lib/spank/interceptor_registration.rb
spank-0.0.1369197478 lib/spank/interceptor_registration.rb