Sha256: 5f7bf52959294d911a776f678e12ee112fcdc5730565836472f43a1b6392f37a

Contents?: true

Size: 732 Bytes

Versions: 2

Compression:

Stored size: 732 Bytes

Contents

module Pact
  module ActiveSupportSupport

    extend self

    def fix_all_the_things thing
      if thing.is_a?(Regexp)
        fix_regexp(thing)
      elsif thing.is_a?(Array)
        thing.each{ | it | fix_all_the_things it }
      elsif thing.is_a?(Hash)
          thing.values.each{ | it | fix_all_the_things it }
      elsif thing.class.name.start_with?("Pact")
        thing.instance_variables.collect{ | iv_name | thing.instance_variable_get(iv_name)}.each do | iv |
          fix_all_the_things iv
        end
      end
      thing
    end

    def fix_regexp regexp
      def regexp.as_json options = {}
        {:json_class => 'Regexp', "o" => self.options, "s" => self.source }
      end
      regexp
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-1.0.19 lib/pact/consumer_contract/active_support_support.rb
pact-1.0.18 lib/pact/consumer_contract/active_support_support.rb