Class: DTest::SharedContext::Manager

Inherits:
Object
  • Object
show all
Includes:
Hook, Singleton
Defined in:
lib/dtest/shared_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hook

#exec

Methods included from Singleton

#remove_instance_var

Constructor Details

#initializeManager

Returns a new instance of Manager.



14
15
16
# File 'lib/dtest/shared_context.rb', line 14

def initialize
  clear
end

Instance Attribute Details

#contextsObject (readonly)

Returns the value of attribute contexts.



12
13
14
# File 'lib/dtest/shared_context.rb', line 12

def contexts
  @contexts
end

Instance Method Details

#add(name, option, &block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/dtest/shared_context.rb', line 27

def add(name, option, &block)
  file, line, = DTest::failure_line(caller(2).first)
  str = ["#{name} context already defined"]
  str << " in #{file}:#{line}" if file && line
  raise str.join("\n") if @contexts.has_key?(name)

  @contexts[name] = block
end

#clearObject



18
19
20
21
# File 'lib/dtest/shared_context.rb', line 18

def clear
  remove_instance_var
  @contexts = {}
end

#has_key?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/dtest/shared_context.rb', line 23

def has_key?(name)
  @contexts.has_key?(name)
end