Created
November 25, 2009 18:50
-
-
Save djtal/242934 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
| module Ludomanager | |
| module ARMustache | |
| # any method placed here will apply to classes, like Hickwall | |
| def mustache_attrs(*attrs) | |
| cattr_accessor :mustache_attrs | |
| self.mustache_attrs = attrs | |
| send :include, InstanceMethods | |
| end | |
| module InstanceMethods | |
| # any method placed here will apply to instances, like @hickwall | |
| def to_mustache_attr | |
| self.mustache_attrs.inject({}) do |hash, attr| | |
| hash[attr] = self.send(attr) | |
| hash | |
| end | |
| end | |
| end | |
| end | |
| end | |
| ActiveRecord::Base.extend Ludomanager::ARMustache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment