Sha256: 61fb130b3743ed5203324af14aa54f46ce486ee071f33dea0004ed87e3abd5db

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 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
# =============================================================================
#++

module Needle
  module Models

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

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

      # Invoke the callback that was given when the service model was
      # instantiated, passing the service model's container reference.
      def instance
        @callback.call( @container )
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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