Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pluckify

Pluckify allows you to pluck to Hash, OpenStruct or any custom class like presenters.

Inspired by pluck_to_hash gem (github).

Usage

# Hash (only column name args)
User.limit(10).pluckify(:id, :first_name, 'users.last_name as last_name')
# => [ { id: 1, first_name: 'Romain', last_name: 'de Landesen' } ]

# OpenStruct
Administrator.where(id: 1).pluckify(:id, :first_name, :last_name, OpenStruct)
# => [ <#OpenStruct id=1, first_name="Romain", last_name="de Landesen"> ]

# Custom Presenter
Administrator.pluckify(:id, :first_name, :last_name, AdministratorPresenter)
# => [ #<AdministratorPresenter @model=#<OpenStruct id=1, first_name="Judge", last_name="Dredd">> ]

Installation

Add this line to your application's Gemfile:

gem 'pluckify', github: 'rdelandesen/pluckify'

And then execute:

$ bundle install

License

The gem is available as open source under the terms of the MIT License.

About

Pluckify allows you to pluck to Hash, OpenStruct or any custom class like presenters.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages