webhook_event_serializer.rb 472 B

1234567891011121314151617181920212223242526
  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. else
  10. super
  11. end
  12. end
  13. attributes :event, :created_at
  14. has_one :virtual_object, key: :object
  15. def virtual_object
  16. object.object
  17. end
  18. def event
  19. object.type
  20. end
  21. end