Class: Method
- Inherits:
-
Object
- Object
- Method
- Defined in:
- lib/method_extensions.rb
Instance Attribute Summary collapse
-
#inline_tests ⇒ Object
Returns the value of attribute inline_tests.
Instance Method Summary collapse
-
#[](*parameters) ⇒ Object
Expose a shorthand for .call.
- #run_inline_tests ⇒ Object
Instance Attribute Details
#inline_tests ⇒ Object
Returns the value of attribute inline_tests.
2 3 4 |
# File 'lib/method_extensions.rb', line 2 def inline_tests @inline_tests end |
Instance Method Details
#[](*parameters) ⇒ Object
Expose a shorthand for .call
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/method_extensions.rb', line 5 def [](*parameters) homogenized_parameters = homogenized_list_of_arrays(parameters) permutation_lookup = {} all_range_permutations = permutations_of_list_of_ranges(homogenized_parameters) all_range_permutations.each do |parameter_permutation| permutation_lookup[parameter_permutation] = call(*parameter_permutation) end should_reduce_results = permutation_lookup.values.uniq.count == 1 if should_reduce_results permutation_lookup.values.first else permutation_lookup end end |
#run_inline_tests ⇒ Object
23 24 25 |
# File 'lib/method_extensions.rb', line 23 def run_inline_tests inline_tests.call self if inline_tests && inline_tests.respond_to?(:call) end |