You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
852 B

  1. # frozen_string_literal: true
  2. class InlineRenderer
  3. def initialize(object, current_account, template)
  4. @object = object
  5. @current_account = current_account
  6. @template = template
  7. end
  8. def render
  9. case @template
  10. when :status
  11. serializer = REST::StatusSerializer
  12. when :notification
  13. serializer = REST::NotificationSerializer
  14. when :conversation
  15. serializer = REST::ConversationSerializer
  16. else
  17. return
  18. end
  19. serializable_resource = ActiveModelSerializers::SerializableResource.new(@object, serializer: serializer, scope: current_user, scope_name: :current_user)
  20. serializable_resource.as_json
  21. end
  22. def self.render(object, current_account, template)
  23. new(object, current_account, template).render
  24. end
  25. private
  26. def current_user
  27. @current_account&.user
  28. end
  29. end