闭社主体 forked from https://github.com/tootsuite/mastodon
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.

33 lines
781 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. else
  15. return
  16. end
  17. serializable_resource = ActiveModelSerializers::SerializableResource.new(@object, serializer: serializer, scope: current_user, scope_name: :current_user)
  18. serializable_resource.as_json
  19. end
  20. def self.render(object, current_account, template)
  21. new(object, current_account, template).render
  22. end
  23. private
  24. def current_user
  25. @current_account&.user
  26. end
  27. end