Guest User

Untitled

a guest
Apr 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. module Ludomanager
  2. module ARMustache
  3.  
  4. # any method placed here will apply to classes, like Hickwall
  5. def mustache_attrs(*attrs)
  6. cattr_accessor :mustache_attrs
  7. self.mustache_attrs = attrs
  8. send :include, InstanceMethods
  9. end
  10.  
  11. module InstanceMethods
  12. # any method placed here will apply to instances, like @hickwall
  13. def to_mustache_attr
  14. self.mustache_attrs.inject({}) do |hash, attr|
  15. hash[attr] = self.send(attr)
  16. hash
  17. end
  18. end
  19. end
  20.  
  21. end
  22.  
  23. end
  24.  
  25. ActiveRecord::Base.extend Ludomanager::ARMustache
Add Comment
Please, Sign In to add comment