Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Determines what includes you need to avoid n+1 queries when using ActiveModel::Serializers
Ruby JavaScript CoffeeScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
gemfiles
lib
spec
.gitattributes
.gitignore
.rspec
.travis.yml
Appraisals
CHANGELOG.md
Gemfile
Gemfile.lock
LICENSE
README-dev.md
README.md
Rakefile
yodo.gemspec

README.md

Build Status Gem Version

Yodo

Determines what includes you need to avoid n+1 queries when using ActiveModel::Serializers.

Usage

If you already have a Rails project setup with ActiveModels::Serializers, add this to your Gemfile:

gem 'yodo', '~> 0.0.1'

Then:

bundle install

In console:

rails c

Do the following:

require 'yodo/ams'

# Get includes required as hash

Yodo::AMS.analyze_all

# That might return {AlphaSerializer=>{:suggested_includes=>[:deltas, :gam, :beta, :alpha, {:delts=>[:delts]}]}, GammaSerializer=>{:suggested_includes=>[]}, DeltaSerializer=>{:suggested_includes=>[:delts]}, BetaSerializer=>{:suggested_includes=>[:gammas, :gamma, :deltas, :ds, :beta, :gam, :bet, {:al=>[:deltas, :gam, :beta, :alpha, {:delts=>[:delts]}]}]}}

# Take the results of Yodo::AMS.analyze_all and sort results in a human readable format

Yodo::AMS.analyze_all.map {|s,h| h.map {|k,v| "#{s.name} #{k.to_s.gsub('_',' ')} = #{v}" unless v.empty?}.compact}.flatten.sort.each {|a| puts a}; nil

# That might output:
#
# AlphaSerializer suggested includes = [:deltas, :gam, :beta, :alpha, {:delts=>[:delts]}]
# BetaSerializer suggested includes = [:gammas, :gamma, :deltas, :ds, :beta, :gam, :bet, {:al=>[:deltas, :gam, :beta, :alpha, {:delts=>[:delts]}]}]
# DeltaSerializer suggested includes = [:delts]

Release Notes

See the Changelog for basically what happened when, and git log for everything else.

Contributing

Please fork, make changes in a separate branch, and do a pull request for your branch.

Contributors

License

Copyright (c) 2013 Gary S. Weaver, released under the MIT license.

Something went wrong with that request. Please try again.