2024-02-23 21:08:51 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class QuickSearchSerializer < ActiveModel::Serializer
|
|
|
|
include Rails.application.routes.url_helpers
|
|
|
|
include BreadcrumbsHelper
|
|
|
|
|
|
|
|
attributes :updated_at, :archived, :breadcrumbs, :code
|
|
|
|
|
|
|
|
def archived
|
2024-05-20 16:35:06 +08:00
|
|
|
@object.respond_to?(:archived_branch?) ? @object.archived_branch? : @object.archived?
|
2024-02-23 21:08:51 +08:00
|
|
|
rescue StandardError
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def code
|
2024-05-21 00:22:32 +08:00
|
|
|
@object.code if @object.respond_to?(:code)
|
2024-02-23 21:08:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def updated_at
|
|
|
|
I18n.l(@object.updated_at, format: :full_date)
|
|
|
|
end
|
|
|
|
|
|
|
|
def breadcrumbs
|
|
|
|
generate_breadcrumbs(@object, [])
|
|
|
|
end
|
|
|
|
end
|