Class: Tryouts::Tryout::DrillContext
- Inherits:
-
Object
- Object
- Tryouts::Tryout::DrillContext
- 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
-
#stash(*args) ⇒ Object
If called with no arguments, returns @stash.
Instance Method Summary collapse
-
#has_dream? ⇒ Boolean
Set to to true by DrillContext#dream.
-
#initialize ⇒ DrillContext
constructor
A new instance of DrillContext.
Constructor Details
#initialize ⇒ DrillContext
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
17 |
# File 'lib/tryouts/drill/context.rb', line 17 def has_dream?; @has_dream; end |