Guest User

Untitled

a guest
Apr 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. module RhoHelper
  2. module ClassMethods
  3. # Receives an array of AR Objects and returns a hash of hashes with each
  4. # item being like: { "id" => { 'attribute_1' => value_1 } }
  5. def hashinate(result)
  6. hash = {}
  7. result.each do |p|
  8. attrs = p.attributes.reject { |key, value| value.is_a? Time }
  9. hash[p.id.to_s] = attrs
  10. end
  11. hash
  12. end
  13.  
  14. def hashinate_all
  15. hash = hashinate(find(:all))
  16. end
  17. end
  18.  
  19. module InstanceMethods
  20.  
  21. end
  22.  
  23. def self.included(receiver)
  24. receiver.extend ClassMethods
  25. receiver.send :include, InstanceMethods
  26. end
  27. end
Add Comment
Please, Sign In to add comment