Module: Kintama::Context
- Defined in:
- lib/kintama/context.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #after_setup_blocks ⇒ Object
- #setup ⇒ Object
- #setup_blocks ⇒ Object
- #teardown ⇒ Object
- #teardown_blocks ⇒ Object
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_blocks ⇒ Object
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 |
#setup ⇒ Object
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_blocks ⇒ Object
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 |
#teardown ⇒ Object
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_blocks ⇒ Object
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 |