Class: Polyrun::Hooks::Dsl::FileContext

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrun/hooks/dsl.rb

Overview

Evaluates a hook file with before / after (+before(:suite)+, etc.).

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#registryObject (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_fileObject



52
53
54
55
# File 'lib/polyrun/hooks/dsl.rb', line 52

def load_file
  instance_eval(File.read(@path), @path)
  @registry
end