Module: BenchmarkSpec::SharedContext
- Included in:
- BenchmarkSpec
- Defined in:
- lib/benchmark_spec/shared_context.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/benchmark_spec/shared_context.rb', line 3 def self.included(klass) klass.class_eval do @@shared_context ||= {} class << klass def shared_context(context_name, &block) @@shared_context[context_name] = block end end end end |
Instance Method Details
#include_context(context_name) ⇒ Object
16 17 18 19 |
# File 'lib/benchmark_spec/shared_context.rb', line 16 def include_context(context_name) raise "Shared context #{context_name.to_s} does not exist!" if @@shared_context[context_name].nil? instance_eval &@@shared_context[context_name] end |