No commit activity in last 3 years
No release in over 3 years
A Rails patch for ActiveSupport::CoreExtensions::Hash#to_query which removes the call for `sort!`
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.9
~> 10.0

Runtime

 Project Readme

UnsortedToQuery

A Rails patch for ActiveSupport::CoreExtensions::Hash#to_query which removes the call for sort!

Requires: >= Ruby 2.0.0

Why I did this

I find this feature important on a lot of projects that i've been working since I've been using .to_query a lot so I decided to put it on a gem.

Installation

Add this line to your application's Gemfile:

gem 'unsorted_to_query'

And then execute:

$ bundle

Or install it yourself as:

$ gem install unsorted_to_query

Usage

This patch is using Refinements. To learn more about it, click here

NOTE: From ruby-doc.org

You may only activate refinements at top-level, not inside any class, module or method scope. You may activate refinements in a string passed to Kernel#eval that is evaluated at top-level. Refinements are active until the end of the file or the end of the eval string, respectively.

class Foo
  using UnsortedToQuery
  
  def self.test
    { foo: 'bar', buzz: 'fizz' }.to_query
  end
end

Foo.test
#=> "foo=bar&buzz=fizz" 

Test

$ ruby test/test_unsorted_to_query.rb

Contributing

  1. Fork it ( https://github.com/[my-github-username]/unsorted_to_query/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request