2018-09-05 15:55:04 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Api
|
|
|
|
module V1
|
2018-10-07 01:53:31 +08:00
|
|
|
class TaskSerializer < ActiveModel::Serializer
|
2018-09-07 17:58:02 +08:00
|
|
|
type :tasks
|
2018-10-07 15:45:24 +08:00
|
|
|
attributes :id, :name, :due_date, :description, :state, :archived
|
2018-11-28 18:33:00 +08:00
|
|
|
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
|
2018-09-05 15:55:04 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|