Sha256: 27ed0bf77fa821dacadda4e86ea7ab30ca8a1d9eaba332cbad5d6d888ca4f727

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

#--
# =============================================================================
# Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu)
# All rights reserved.
#
# This source file is distributed as part of the Needle dependency injection
# library for Ruby. This file (and the library as a whole) may be used only as
# allowed by either the BSD license, or the Ruby license (or, by association
# with the Ruby license, the GPL). See the "doc" subdirectory of the Needle
# distribution for the texts of these licenses.
# -----------------------------------------------------------------------------
# needle website : http://needle.rubyforge.org
# project website: http://rubyforge.org/projects/needle
# =============================================================================
#++

require 'needle/models/proxy'

module Needle
  module Models

    # The definition of the "prototype-deferred" lifecycle service model.
    # This will result in deferred instantiation of the requested service,
    # with a new instance being returned every time #instance is invoked.
    class PrototypeDeferred

      # Create a new PrototypeDeferred service model.
      def initialize( container, opts={}, &callback )
        @container = container
        @callback = callback
      end

      # Return a new Proxy instance that wraps the container and callback
      # references given when the service model was instantiated.
      def instance
        Proxy.new( @container, &@callback )
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
needle-0.5.0 lib/needle/models/prototype-deferred.rb