Sha256: 3a70becc7168cbd8dd9939b5df371ccea87e76fe22ab92d3369577449c3f4069

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

module Alf
  class Environment
    #
    # Specialization of Environment that works with explicitely defined 
    # datasources and allow branching and unbranching.
    #
    class Explicit < Environment
      
      #
      # Creates a new environment instance with initial definitions
      # and optional child environment.
      #
      def initialize(defs = {}, child = nil)
        @defs = defs
        @child = child
      end
      
      # 
      # Unbranches this environment and returns its child
      #
      def unbranch
        @child
      end
      
      # (see Environment#dataset)
      def dataset(name)
        if @defs.has_key?(name)
          @defs[name]
        elsif @child
          @child.dataset(name)
        else
          raise NoSuchDatasetError, "No such dataset #{name}"
        end 
      end
      
    end # class Explicit
  end # class Environment
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.10.1 lib/alf/environment/explicit.rb