Sha256: 5f2de425095d96bff5bdb03e3022f1640a86dd2c1f2724688e4dddbf219615c5

Contents?: true

Size: 531 Bytes

Versions: 1

Compression:

Stored size: 531 Bytes

Contents

module Ruby3BackwardCompatibility
  module Ruby3Keywords
    def ruby3_keywords(*methods)
      methods.each do |method|
        _ruby3_keywords_module.define_method(method) do |*args, **keyword_args|
          if args.last.is_a?(Hash)
            keyword_args.merge!(args.pop)
          end
          super(*args, **keyword_args)
        end
      end
    end

    private

    def _ruby3_keywords_module
      @_ruby3_keywords_module ||= begin
        mod = Module.new
        prepend mod
        mod
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby3-backward-compatibility-0.1.1 lib/ruby3_backward_compatibility/ruby3_keywords.rb