2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-24 13:45:35 -05:00
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
2015-11-30 14:22:58 -06:00
|
|
|
attributes :id, :value, :overridden?, :can_revert?
|
2014-09-24 13:45:35 -05:00
|
|
|
|
2015-08-07 13:05:08 -05:00
|
|
|
def id
|
2015-11-23 15:45:05 -06:00
|
|
|
object[:id]
|
2014-09-24 13:45:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
2015-11-23 15:45:05 -06:00
|
|
|
object[:value]
|
2014-09-24 13:45:35 -05:00
|
|
|
end
|
|
|
|
|
2015-11-30 14:22:58 -06:00
|
|
|
def overridden?
|
2019-07-01 20:53:16 -05:00
|
|
|
if options[:overridden_keys]
|
|
|
|
options[:overridden_keys].include?(object[:id])
|
2019-05-10 18:52:27 -05:00
|
|
|
else
|
2021-01-20 14:43:00 -06:00
|
|
|
TranslationOverride.exists?(locale: object[:locale], translation_key: object[:id])
|
2015-11-23 15:45:05 -06:00
|
|
|
end
|
2014-09-24 13:45:35 -05:00
|
|
|
end
|
2015-11-30 14:22:58 -06:00
|
|
|
|
|
|
|
alias_method :can_revert?, :overridden?
|
2014-09-24 13:45:35 -05:00
|
|
|
end
|