2014-09-25 02:45:35 +08:00
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
|
|
|
|
2015-08-08 02:05:08 +08:00
|
|
|
attributes :id,
|
|
|
|
:text_type,
|
2014-09-25 02:45:35 +08:00
|
|
|
:title,
|
|
|
|
:description,
|
|
|
|
:value,
|
|
|
|
:format,
|
|
|
|
:allow_blank?
|
|
|
|
|
2015-08-08 02:05:08 +08:00
|
|
|
def id
|
|
|
|
text_type
|
|
|
|
end
|
|
|
|
|
2014-09-25 02:45:35 +08:00
|
|
|
def title
|
|
|
|
object.site_text_type.title
|
|
|
|
end
|
|
|
|
|
|
|
|
def text_type
|
|
|
|
object.text_type
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
object.site_text_type.description
|
|
|
|
end
|
|
|
|
|
|
|
|
def format
|
|
|
|
object.site_text_type.format
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
|
|
|
return object.value if object.value.present?
|
|
|
|
object.site_text_type.default_text
|
|
|
|
end
|
|
|
|
|
|
|
|
def allow_blank?
|
|
|
|
object.site_text_type.allow_blank?
|
|
|
|
end
|
|
|
|
end
|