Module: Kintama::Context

Defined in:
lib/kintama/context.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



46
47
48
# File 'lib/kintama/context.rb', line 46

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#after_setup_blocksObject



26
27
28
29
30
31
32
33
34
# File 'lib/kintama/context.rb', line 26

def after_setup_blocks
  context = self.class
  blocks = context.after_setup_blocks
  while(context.superclass.respond_to?(:after_setup_blocks))
    context = context.superclass
    blocks.unshift(*context.after_setup_blocks)
  end
  blocks
end

#setupObject



3
4
5
6
7
# File 'lib/kintama/context.rb', line 3

def setup
  (setup_blocks + after_setup_blocks).each do |block|
    instance_eval(&block)
  end
end

#setup_blocksObject



16
17
18
19
20
21
22
23
24
# File 'lib/kintama/context.rb', line 16

def setup_blocks
  context = self.class
  blocks = context.setup_blocks
  while(context.superclass.respond_to?(:setup_blocks))
    context = context.superclass
    blocks.unshift(*context.setup_blocks)
  end
  blocks
end

#teardownObject



9
10
11
12
13
14
# File 'lib/kintama/context.rb', line 9

def teardown
  blocks = teardown_blocks
  blocks.each do |block|
    instance_eval(&block)
  end
end

#teardown_blocksObject



36
37
38
39
40
41
42
43
44
# File 'lib/kintama/context.rb', line 36

def teardown_blocks
  context = self.class
  blocks = context.teardown_blocks
  while(context.superclass.respond_to?(:teardown_blocks))
    context = context.superclass
    blocks.push(*context.teardown_blocks)
  end
  blocks
end