Guest User

Untitled

a guest
Jun 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. module FCG
  2. module Client
  3. module Comment
  4. ATTRIBUTES = [:site, :record, :body, :body_as_html, :deleted, :flagged_by, :depth, :path, :parent_id, :displayed_name, :user_id]
  5.  
  6. module ClassMethods
  7. def find_by_record(record)
  8. request = Typhoeus::Request.new(
  9. "#{self.service_url}/find_by_record/#{record}",
  10. :method => :get)
  11.  
  12. request.on_complete do |response|
  13. response
  14. end
  15.  
  16. self.hydra.queue(request)
  17. self.hydra.run
  18.  
  19. handle_service_response request.handled_response
  20. end
  21. end
  22.  
  23. module InstanceMethods
  24. # included from mongo's social plugin
  25. def comment_info
  26. {
  27. :id => self.id,
  28. :site => self.site,
  29. :record => self.record,
  30. :body => self.body,
  31. :body_as_html => self.body_as_html,
  32. :flagged_by => self.flagged_by,
  33. :depth => self.depth,
  34. :path => self.path,
  35. :parent_id => self.parent_id,
  36. :displayed_name => self.displayed_name,
  37. :user_id => self.user_id
  38. }
  39. end
  40.  
  41. protected
  42. def setup
  43. self.deleted = false
  44. end
  45. end
  46.  
  47. def self.included(receiver)
  48.  
  49. receiver.extend ClassMethods
  50. receiver.send :include, FCG::Client::Persistence
  51. receiver.send :include, InstanceMethods
  52.  
  53. receiver.validates_presence_of :site
  54. receiver.validates_presence_of :record
  55. receiver.validates_presence_of :body
  56. receiver.validates_presence_of :user_id
  57. end
  58. end
  59. end
  60. end
Add Comment
Please, Sign In to add comment