Sha256: b2bfbe71547729fcd9491ff911e0b67aae77f00f836a2beea9bc4aa0d50d7be7

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

module ActiveMocker
class Reparameterize

  def self.call(params, param_list:nil)
    return param_list(params) unless param_list.nil?
    method_arguments(params)
  end

  def self.method_arguments(params)
    params.map do |state, param|
      case state
        when :req
          param
        when :rest
          "*#{param}"
        when :opt
          "#{param}=nil"
        when :keyreq
          "#{param}:"
        when :key
          "#{param}: nil"
      end
    end.join(', ')

  end

  def self.param_list(params)
    params.map do |state, param|
      case state
        when :key, :keyreq
          "#{param}: #{param}"
        else
          param
      end
    end.join(', ')
  end

end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_mocker-1.5.2 lib/active_mocker/reparameterize.rb
active_mocker-1.5.1 lib/active_mocker/reparameterize.rb
active_mocker-1.5 lib/active_mocker/reparameterize.rb