mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 10:14:17 +08:00
16 lines
572 B
Ruby
16 lines
572 B
Ruby
# frozen_string_literal: true
|
|
|
|
class StepOrderableElementSerializer < ActiveModel::Serializer
|
|
attributes :position, :orderable, :orderable_type
|
|
|
|
def orderable
|
|
case object.orderable_type
|
|
when 'Checklist'
|
|
ChecklistSerializer.new(object.orderable, scope: { user: @instance_options[:user] }).as_json
|
|
when 'StepTable'
|
|
TableSerializer.new(object.orderable.table, scope: { user: @instance_options[:user] }).as_json
|
|
when 'StepText'
|
|
StepTextSerializer.new(object.orderable, scope: { user: @instance_options[:user] }).as_json
|
|
end
|
|
end
|
|
end
|