Sha256: d8e82922b2abc966cfdb09a355e7cae37bcb1fb6c69e4e7d4a49fc4933161fe5

Contents?: true

Size: 633 Bytes

Versions: 6

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

# :nodoc:
# @api private
class String
  # :nodoc:
  # @api private
  def to_route_param
    return self if start_with?(":")

    ":#{+self}"
  end unless method_defined?(:to_route_param)
end

# :nodoc:
# @api private
class Symbol
  # :nodoc:
  # @api private
  def to_route_param
    to_s.to_route_param
  end unless method_defined?(:to_route_param)
end

# :nodoc:key => "value",
# @api private
class Hash
  # :nodoc:
  # @api private
  def to_route_param
    each_with_object({}) do |(key, value), memo|
      memo[key.to_route_param] = value
    end
  end unless method_defined?(:to_route_param)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stub_requests-0.1.11 lib/stub_requests/core_ext/string/to_route_param.rb
stub_requests-0.1.10 lib/stub_requests/core_ext/string/to_route_param.rb
stub_requests-0.1.9 lib/stub_requests/core_ext/string/to_route_param.rb
stub_requests-0.1.8 lib/stub_requests/core_ext/string/to_route_param.rb
stub_requests-0.1.7 lib/stub_requests/core_ext/string/to_route_param.rb
stub_requests-0.1.6 lib/stub_requests/core_ext/string/to_route_param.rb