1
0
Fork 0
discourse-custom-wizard-unl.../app/serializers/custom_wizard/api_serializer.rb
2022-03-12 14:00:07 +01:00

36 Zeilen
845 B
Ruby

# frozen_string_literal: true
class CustomWizard::ApiSerializer < ::ApplicationSerializer
attributes :name,
:title,
:authorization,
:endpoints,
:log
def authorization
if authorization = CustomWizard::Api::Authorization.get(object.name)
CustomWizard::Api::AuthorizationSerializer.new(
authorization,
root: false
)
end
end
def endpoints
if endpoints = CustomWizard::Api::Endpoint.list(object.name)
ActiveModel::ArraySerializer.new(
endpoints,
each_serializer: CustomWizard::Api::EndpointSerializer
)
end
end
def log
if log = CustomWizard::Api::LogEntry.list(object.name)
ActiveModel::ArraySerializer.new(
log,
each_serializer: CustomWizard::Api::LogSerializer
)
end
end
end