2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-19 05:15:46 +08:00
|
|
|
class EmbeddableHostSerializer < ApplicationSerializer
|
2024-05-17 03:47:01 +08:00
|
|
|
TO_SERIALIZE = %i[id host allowed_paths class_name category_id tags user]
|
2015-08-19 05:15:46 +08:00
|
|
|
|
2016-08-24 02:55:52 +08:00
|
|
|
attributes *TO_SERIALIZE
|
2015-08-19 05:15:46 +08:00
|
|
|
|
2019-05-07 09:27:05 +08:00
|
|
|
TO_SERIALIZE.each { |attr| define_method(attr) { object.public_send(attr) } }
|
2024-05-17 03:47:01 +08:00
|
|
|
|
|
|
|
def user
|
|
|
|
object.user&.username
|
|
|
|
end
|
|
|
|
|
|
|
|
def tags
|
|
|
|
object.tags.map(&:name)
|
|
|
|
end
|
2016-08-24 02:55:52 +08:00
|
|
|
end
|