Skip to content

Instantly share code, notes, and snippets.

@djtal
Created November 25, 2009 18:50
Show Gist options
  • Select an option

  • Save djtal/242934 to your computer and use it in GitHub Desktop.

Select an option

Save djtal/242934 to your computer and use it in GitHub Desktop.
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