mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +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
|