Sha256: cbe525fd3a790502a3d986e669f35b11205fca4c1daf675c2a282c2d46cbce74

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

unless Method.method_defined?(:curry)

  # Backport
  #
  # Ruby 2.1 and lower implement curry only for Procs.
  #
  # Why not using Refinements? Because they don't work for Method (tested with ruby 2.1.9).
  #
  module CurryMethods # :nodoc:
    # Backport for the Method#curry method, which is part of ruby core since 2.2 .
    #
    def curry(*args)
      to_proc.curry(*args)
    end
  end
  Method.__send__(:include, CurryMethods)
end

unless String.method_defined?(:+@)
  # Backport for +"", to initialize unfrozen strings from the string literal.
  #
  module LiteralStringExtensions
    def +@
      frozen? ? dup : self
    end
  end
  String.__send__(:include, LiteralStringExtensions)
end

unless Numeric.method_defined?(:positive?)
  # Ruby 2.3 Backport (Numeric#positive?)
  #
  module PosMethods
    def positive?
      self > 0
    end
  end
  Numeric.__send__(:include, PosMethods)
end

unless Numeric.method_defined?(:negative?)
  # Ruby 2.3 Backport (Numeric#negative?)
  #
  module NegMethods
    def negative?
      self < 0
    end
  end
  Numeric.__send__(:include, NegMethods)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
httpx-0.2.1 lib/httpx/extensions.rb
httpx-0.2.0 lib/httpx/extensions.rb
httpx-0.1.0 lib/httpx/extensions.rb
httpx-0.0.5 lib/httpx/extensions.rb
httpx-0.0.4 lib/httpx/extensions.rb
httpx-0.0.3 lib/httpx/extensions.rb
httpx-0.0.2 lib/httpx/extensions.rb
httpx-0.0.1 lib/httpx/extensions.rb