Pluckex
Pluckex add pluck-extended methods.
ActiveRecord::Caluculations#pluck.
Like this.
pluck_tied_by_id
# one arg case:
# Person.pluck_tied_by_id(:name)
# # => {1=>'David', 2=>'Jeremy', 3=>'Jose'}
#
# multiple args case:
# Person.pluck_tied_by_id(:name, :age)
# # => {1=>{:name=>"David", :age=>25}, 2=>{:name=>"Jeremy", :age=>27}}
pluck_with_keys
# Person.pluck_with_keys(:id, :name)
# # => [{:id=>1, :name=>'David'}, {:id=>2, :name=>'Jeremy'}, {:id=>3, :name=>'Jose'}]
Installation
Add this line to your application's Gemfile:
gem 'pluckex'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pluckex
Contributing
- Fork it ( https://github.com/[my-github-username]/pluckex/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request