Sha256: e5964c1d6fb49f8622baa2daffba275560a75e66c9ccae74bcec047d4224f63a

Contents?: true

Size: 600 Bytes

Versions: 17

Compression:

Stored size: 600 Bytes

Contents

module Spank
  class Component
    include LambdaBehaviours

    def initialize(class_key, &block)
      @factory_method = block
      @interceptors = []
    end

    def create(container)
      instance = @factory_method.call(container)
      @interceptors.each do |interceptor|
        instance = interceptor.intercept(instance)
      end
      instance
    end

    def as_singleton
      @factory_method = memoize(@factory_method)
    end

    def intercept(method)
      interceptor = InterceptorRegistration.new(method)
      @interceptors.push(interceptor)
      interceptor
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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