Sha256: 7787398e5cf01a3379bb8d4cd88d1d76d283e977827d1ff13cefe0b19232c94d

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

ohm-tallyable
=============

[![Gem Version](https://badge.fury.io/rb/ohm-tallyable.png)](http://badge.fury.io/rb/ohm-tallyable)
[![Code Climate](https://codeclimate.com/github/educabilia/ohm-tallyable.png)](https://codeclimate.com/github/educabilia/ohm-tallyable)

A tally plugin for Ohm


Setup
-----

1. Include the `Callbacks` and `Tallyable` modules in your model:

		include Ohm::Callbacks 
		include Ohm::Tallyable

2. Add a tally to your model with the following line:

		tally :category

You will need to resave every model if they already exist.

Usage
-----

To query the tallies, use the `leaderboard` class method.

    >> Post.leaderboard(:category)
    => [["Personal", 2], ["Work", 1]]


Advanced Usage
--------------

You can also partition the tally by a certain attribute:

    tally :category, :by => :site_id

You will need to provide a value for this attribute every time you check the
leaderboard:

	Post.leaderboard(:category, :site_id => 'ar') 


Requirements
------------

This plugin works with Ohm versions higher than 0.1.3.


Acknowledgements
----------------

Many thanks to Damian Janowski (https://github.com/djanowski) who took care to
explain me the details of coding an Ohm plugin and providing many ideas on
how to handle certain cases.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ohm-tallyable-0.1.5 README.md