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-06-03 17:52:10 +08:00
|
|
|
ChecklistSerializer.new(object.orderable, scope: { user: @instance_options[:user] }).as_json
|
2022-04-29 18:29:42 +08:00
|
|
|
when 'StepTable'
|
2022-06-03 17:52:10 +08:00
|
|
|
TableSerializer.new(object.orderable.table, scope: { user: @instance_options[:user] }).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
|