scinote-web/app/serializers/api/v1/my_module_serializer.rb

26 lines
672 B
Ruby
Raw Normal View History

2018-09-05 15:55:04 +08:00
# frozen_string_literal: true
module Api
module V1
class MyModuleSerializer < ActiveModel::Serializer
2018-09-06 21:38:48 +08:00
type :task
2018-09-05 15:55:04 +08:00
attributes :id, :name, :due_date, :description, :my_module_group_id, :nr_of_assigned_samples, :state
2018-09-06 21:38:48 +08:00
link(:self) {
api_v1_team_project_experiment_task_url(
return_path[0], return_path[1], return_path[2], object.id
)
}
2018-09-05 15:55:04 +08:00
belongs_to :experiment
2018-09-06 21:38:48 +08:00
def return_path
return_array = []
experiment = object.experiment
project = experiment.project
team = project.team
return_array.push(experiment, project, team)
return_array
end
2018-09-05 15:55:04 +08:00
end
end
end