2017-09-22 23:57:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
|
|
|
include RoutingHelper
|
|
|
|
|
2017-10-27 14:11:30 +00:00
|
|
|
attributes :shortcode, :url, :static_url, :visible_in_picker
|
2017-09-22 23:57:23 +00:00
|
|
|
|
2019-06-28 13:54:10 +00:00
|
|
|
attribute :category, if: :category_loaded?
|
2023-02-20 04:41:47 +00:00
|
|
|
attribute :width, if: :width?
|
|
|
|
attribute :height, if: :height?
|
2019-06-28 13:54:10 +00:00
|
|
|
|
2017-09-22 23:57:23 +00:00
|
|
|
def url
|
|
|
|
full_asset_url(object.image.url)
|
|
|
|
end
|
2017-10-05 21:41:47 +00:00
|
|
|
|
|
|
|
def static_url
|
|
|
|
full_asset_url(object.image.url(:static))
|
|
|
|
end
|
2019-06-28 13:54:10 +00:00
|
|
|
|
|
|
|
def category
|
|
|
|
object.category.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def category_loaded?
|
|
|
|
object.association(:category).loaded? && object.category.present?
|
|
|
|
end
|
2023-02-20 04:41:47 +00:00
|
|
|
|
|
|
|
def width
|
|
|
|
object.width
|
|
|
|
end
|
|
|
|
|
|
|
|
def height
|
|
|
|
object.height
|
|
|
|
end
|
|
|
|
|
|
|
|
def width?
|
|
|
|
!object.width.nil?
|
|
|
|
end
|
|
|
|
|
|
|
|
def height?
|
|
|
|
!object.height.nil?
|
|
|
|
end
|
2017-09-22 23:57:23 +00:00
|
|
|
end
|