RelationToStruct
When one needs to use ActiveRecord to fetch specific values (whether subset columns of a model or arbitrary calculated columns), it's desirable to avoid the overhead of model instances and any associated callbacks.
ActiveRecord::Relation#pluck solves a similar problem but returns tuples; I wanted to be able to return Ruby structs to benefit from named instance methods.
Installation
Add this line to your application's Gemfile:
gem 'relation_to_struct'
And then execute:
$ bundle
Or install it yourself as:
$ gem install relation_to_struct
Usage
TODO: Write usage instructions here
Contributing
- Fork it ( https://github.com/[my-github-username]/relation_to_struct/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