webhook_event_serializer.rb 519 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer
  3. def self.serializer_for(model, options)
  4. case model.class.name
  5. when 'Account'
  6. REST::Admin::AccountSerializer
  7. when 'Report'
  8. REST::Admin::ReportSerializer
  9. when 'Status'
  10. REST::StatusSerializer
  11. else
  12. super
  13. end
  14. end
  15. attributes :event, :created_at
  16. has_one :virtual_object, key: :object
  17. def virtual_object
  18. object.object
  19. end
  20. def event
  21. object.type
  22. end
  23. end