2022-04-29 18:29:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class StepOrderableElementSerializer < ActiveModel::Serializer
|
2022-05-05 18:56:31 +08:00
|
|
|
attributes :position, :orderable, :orderable_type
|
2022-04-29 18:29:42 +08:00
|
|
|
|
2022-05-05 18:56:31 +08:00
|
|
|
def orderable
|
2022-04-29 18:29:42 +08:00
|
|
|
case object.orderable_type
|
|
|
|
when 'Checklist'
|
2022-05-03 19:42:43 +08:00
|
|
|
ChecklistSerializer.new(object.orderable).as_json
|
2022-04-29 18:29:42 +08:00
|
|
|
when 'StepTable'
|
2022-05-06 17:59:22 +08:00
|
|
|
TableSerializer.new(object.orderable.table).as_json
|
2022-04-29 18:29:42 +08:00
|
|
|
when 'StepText'
|
2022-05-10 19:28:09 +08:00
|
|
|
StepTextSerializer.new(object.orderable, scope: { user: @instance_options[:user] }).as_json
|
2022-04-29 18:29:42 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|