Sha256: fab1b765c79d5be48d8460887f145d1cda8b02b34a4032db7cf6e6795bd6cc58

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 Bytes

Contents

module Scorpion
  # A scorpion factory
  class Nest

    # ============================================================================
    # @!group Associations
    #

    # @!attribute
    # @return [Scorpion] the mother scorpion that that will {#conceive} new
    #   scorpions for each request.
      attr_reader :mother

    #
    # @!endgroup Associations

    def initialize( mother = nil )
      @mother = mother || Scorpion::Hunter.new
    end

    def prepare( &block )
      mother.prepare &block
    end

    # @return [Scorpion] a new scorpion used to hunt for dependencies.
    def conceive
      mother.replicate
    end

    # Free up any persistent resources
    def destroy
      mother.destroy
      @mother = nil
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scorpion-ioc-0.4.0 lib/scorpion/nest.rb
scorpion-ioc-0.3.1 lib/scorpion/nest.rb
scorpion-ioc-0.3.0 lib/scorpion/nest.rb
scorpion-ioc-0.2.0 lib/scorpion/nest.rb
scorpion-ioc-0.1.0 lib/scorpion/nest.rb