Sha256: 44b38e7b95736bcd30017e421f625bb86544650848ad901d396aa016238748c5

Contents?: true

Size: 634 Bytes

Versions: 4

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

unless defined?(NoMatchingPatternError)
  class NoMatchingPatternError < RuntimeError
  end
end

# Add `#deconstruct` and `#deconstruct_keys` to core classes
unless [].respond_to?(:deconstruct)
  RubyNext.module_eval do
    refine Array do
      def deconstruct
        self
      end
    end

    refine Struct do
      alias deconstruct to_a
    end
  end
end

unless {}.respond_to?(:deconstruct_keys)
  RubyNext.module_eval do
    refine Hash do
      def deconstruct_keys(_)
        self
      end
    end

    refine Struct do
      def deconstruct_keys(_)
        to_h
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ruby-next-0.2.0 lib/ruby-next/core/pattern_matching.rb
ruby-next-core-0.2.0 lib/ruby-next/core/pattern_matching.rb
ruby-next-0.1.1 lib/ruby-next/core/pattern_matching.rb
ruby-next-0.1.0 lib/ruby-next/core/pattern_matching.rb