Class: Polyrun::Hooks::Dsl::FileContext
- Inherits:
-
Object
- Object
- Polyrun::Hooks::Dsl::FileContext
- Defined in:
- lib/polyrun/hooks/dsl.rb
Overview
Evaluates a hook file with before / after (+before(:suite)+, etc.).
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #after(sym, &block) ⇒ Object
- #before(sym, &block) ⇒ Object
-
#initialize(path) ⇒ FileContext
constructor
A new instance of FileContext.
- #load_file ⇒ Object
Constructor Details
#initialize(path) ⇒ FileContext
Returns a new instance of FileContext.
45 46 47 48 |
# File 'lib/polyrun/hooks/dsl.rb', line 45 def initialize(path) @path = path @registry = Registry.new end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
50 51 52 |
# File 'lib/polyrun/hooks/dsl.rb', line 50 def registry @registry end |
Instance Method Details
#after(sym, &block) ⇒ Object
61 62 63 |
# File 'lib/polyrun/hooks/dsl.rb', line 61 def after(sym, &block) @registry.add(map_after(sym), block) end |
#before(sym, &block) ⇒ Object
57 58 59 |
# File 'lib/polyrun/hooks/dsl.rb', line 57 def before(sym, &block) @registry.add(map_before(sym), block) end |
#load_file ⇒ Object
52 53 54 55 |
# File 'lib/polyrun/hooks/dsl.rb', line 52 def load_file instance_eval(File.read(@path), @path) @registry end |