File: example_helper_methods.rb

package info (click to toggle)
ruby-rspec-parameterized-core 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ruby: 647; sh: 4; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module RSpec
  module Parameterized
    module Core
      module ExampleHelperMethods
        def recursive_apply(val)
          return val.apply(self) if HelperMethods.applicable?(val)

          if val.is_a?(Array)
            return val.map { |child_val| recursive_apply(child_val) }
          end

          if val.is_a?(Hash)
            return val.map { |key, value| [recursive_apply(key), recursive_apply(value)] }.to_h
          end

          val
        end
      end
    end
  end
end