Sha256: dabc19638804a50ab65e6f88ead07a967b96c509d82e1ec583f484419422119e

Contents?: true

Size: 966 Bytes

Versions: 11

Compression:

Stored size: 966 Bytes

Contents

class Tryouts
  class Tryout
    
    # All :api and :benchmark drills are run within this context. 
    # Each Drill is executed in a new instance of this class. That means
    # instance variables are not carried through, but class variables are. 
    # The before and after blocks are also run in this context.
    class DrillContext
        # An ordered Hash of stashed objects. 
      attr_writer :stash

      def initialize; @stash = Tryouts::HASH_TYPE.new; @has_dream = false; end

      # Set to to true by DrillContext#dream
      def has_dream?; @has_dream; end

      # If called with no arguments, returns +@stash+. 
      # If called with arguments, it will add a new value to the +@stash+
      # and return the new value.  e.g.
      #
      #     stash :name, 'some value'   # => 'some value'
      #
      def stash(*args)
        return @stash if args.empty?
        @stash[args[0]] = args[1] 
        args[1] 
      end
      
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
delano-tryouts-0.8.1 lib/tryouts/drill/context.rb
delano-tryouts-0.8.2 lib/tryouts/drill/context.rb
delano-tryouts-0.8.3 lib/tryouts/drill/context.rb
delano-tryouts-0.8.4 lib/tryouts/drill/context.rb
tryouts-0.8.8 lib/tryouts/drill/context.rb
tryouts-0.8.7 lib/tryouts/drill/context.rb
tryouts-0.8.5 lib/tryouts/drill/context.rb
tryouts-0.8.1 lib/tryouts/drill/context.rb
tryouts-0.8.2 lib/tryouts/drill/context.rb
tryouts-0.8.3 lib/tryouts/drill/context.rb
tryouts-0.8.4 lib/tryouts/drill/context.rb