Output
All attributes the service must return in Result
should be described through the output
method.
Options
Option type
This option is validation.
It will check that the value set to output
corresponds to the specified type (class).
In this case is_a?
method is used.
class NotificationService::Create < ApplicationService::Base
input :user, type: User
output :notification, type: Notification
make :create_notification!
private
def create_notification!
self.notification = Notification.create!(user: inputs.user)
end
end