scinote-web/app/serializers/api/v1/task_serializer.rb
2018-11-28 11:33:00 +01:00

24 lines
647 B
Ruby

# frozen_string_literal: true
module Api
module V1
class TaskSerializer < ActiveModel::Serializer
type :tasks
attributes :id, :name, :due_date, :description, :state, :archived
has_many :output_tasks, key: :outputs,
serializer: TaskSerializer,
class_name: 'MyModule'
has_many :input_tasks, key: :inputs,
serializer: TaskSerializer,
class_name: 'MyModule'
def output_tasks
object.my_modules
end
def input_tasks
object.my_module_antecessors
end
end
end
end