Created
January 27, 2012 23:52
-
-
Save adrianpike/1691655 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #shinypenny DSL | |
| module MyAchievements | |
| include :shiny_penny | |
| translation_scope 'my_achievements' #=> winds up looking like en.my_achievements.ten_deals_closed | |
| achievement :ten_deals_closed do | |
| # What model(s) might trigger this? The achievement matching logic fires after every create/update on these models. | |
| watches :deal | |
| # This is a threshold achievement - when there's N counts in the system, it fires. | |
| threshold 10 | |
| # The number of times this achievement can be unlocked - default is infinite. | |
| count 1 | |
| end | |
| achievement :biggest_deal_ever do | |
| watches :deal | |
| # This is a maximum threshold - pass a column name, and a block to generate an array of values to compare against | |
| maximum :value, { this.user.deals.collect(&:value) } | |
| end | |
| achievement :closed_a_billion_dollars do | |
| watches :deal | |
| # Runs generic logic! | |
| when { this.user.deals.closed.sum('value') >= 1000000000 } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment