Module: BenchmarkSpec::DSL::ClassMethods
- Defined in:
- lib/benchmark_spec/dsl.rb
Instance Method Summary collapse
- #change_global_dsl(context, &changes) ⇒ Object
- #expose_method_dsl_to_context(method, context) ⇒ Object
- #expose_methods_to_context(methods, context) ⇒ Object
Instance Method Details
#change_global_dsl(context, &changes) ⇒ Object
8 9 10 |
# File 'lib/benchmark_spec/dsl.rb', line 8 def change_global_dsl(context, &changes) (class << context; self; end).class_exec(&changes) end |
#expose_method_dsl_to_context(method, context) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/benchmark_spec/dsl.rb', line 12 def expose_method_dsl_to_context(method, context) change_global_dsl(context) do remove_method(method) if method_defined?(method) define_method(method) do |*a, &b| BenchmarkSpec.__send__(method, *a, &b) end end end |
#expose_methods_to_context(methods, context) ⇒ Object
21 22 23 |
# File 'lib/benchmark_spec/dsl.rb', line 21 def expose_methods_to_context(methods, context) methods.each {|meth| expose_method_dsl_to_context(meth, context)} end |