Class: Tryouts::Tryout::DrillContext

Inherits:
Object
  • Object
show all
Defined in:
lib/tryouts/drill/context.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDrillContext

Returns a new instance of DrillContext.



14
# File 'lib/tryouts/drill/context.rb', line 14

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

Instance Attribute Details

#stash(*args) ⇒ Object

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'


25
26
27
28
29
# File 'lib/tryouts/drill/context.rb', line 25

def stash(*args)
  return @stash if args.empty?
  @stash[args[0]] = args[1] 
  args[1] 
end

Instance Method Details

#has_dream?Boolean

Set to to true by DrillContext#dream

Returns:

  • (Boolean)


17
# File 'lib/tryouts/drill/context.rb', line 17

def has_dream?; @has_dream; end