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.
 
 
 
 

41 lines
1.0 KiB

# frozen_string_literal: true
class InlineRenderer
def initialize(object, current_account, template)
@object = object
@current_account = current_account
@template = template
end
def render
case @template
when :status
serializer = REST::StatusSerializer
when :notification
serializer = REST::NotificationSerializer
when :conversation
serializer = REST::ConversationSerializer
when :announcement
serializer = REST::AnnouncementSerializer
when :reaction
serializer = REST::ReactionSerializer
when :encrypted_message
serializer = REST::EncryptedMessageSerializer
else
return
end
serializable_resource = ActiveModelSerializers::SerializableResource.new(@object, serializer: serializer, scope: current_user, scope_name: :current_user)
serializable_resource.as_json
end
def self.render(object, current_account, template)
new(object, current_account, template).render
end
private
def current_user
@current_account&.user
end
end