Sha256: bf0ada3bcfd7d5ba8afac7c8ab329bd7064eda585a4f7b12cd577002aff45d36

Contents?: true

Size: 521 Bytes

Versions: 13

Compression:

Stored size: 521 Bytes

Contents

class BasicObject #:nodoc:
  instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval/ }
end unless defined?(BasicObject)

# monkey patching:
class Hash
  # This is by no means the standard way to transform ruby objects into query parameters
  # but it is targeted at our own needs
  def to_params
    params = ''

    each do |k, v|
      if v.is_a?(Array)
        params << "#{k}=#{v.join(",")}&"
      else
        params << "#{k}=#{v.to_s}&"
      end
    end

    params.chop! 
    params
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
restfully-0.5.10 lib/restfully/extensions.rb
restfully-0.5.9 lib/restfully/extensions.rb
restfully-0.5.8 lib/restfully/extensions.rb
restfully-0.5.7 lib/restfully/extensions.rb
restfully-0.5.6 lib/restfully/extensions.rb
restfully-0.5.5 lib/restfully/extensions.rb
restfully-0.5.4 lib/restfully/extensions.rb
restfully-0.5.3 lib/restfully/extensions.rb
restfully-0.5.2 lib/restfully/extensions.rb
restfully-0.5.1 lib/restfully/extensions.rb
restfully-0.5.0 lib/restfully/extensions.rb
restfully-0.4.1 lib/restfully/extensions.rb
restfully-0.4.0 lib/restfully/extensions.rb