2014-09-25 02:45:35 +08:00
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
2015-12-01 04:22:58 +08:00
|
|
|
attributes :id, :value, :overridden?, :can_revert?
|
2014-09-25 02:45:35 +08:00
|
|
|
|
2015-08-08 02:05:08 +08:00
|
|
|
def id
|
2015-11-24 05:45:05 +08:00
|
|
|
object[:id]
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
2015-11-24 05:45:05 +08:00
|
|
|
object[:value]
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
|
|
|
|
2015-12-01 04:22:58 +08:00
|
|
|
def overridden?
|
2015-11-24 05:45:05 +08:00
|
|
|
current_val = value
|
|
|
|
|
|
|
|
I18n.overrides_disabled do
|
|
|
|
return I18n.t(object[:id]) != current_val
|
|
|
|
end
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
2015-12-01 04:22:58 +08:00
|
|
|
|
|
|
|
alias_method :can_revert?, :overridden?
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
2015-11-24 05:45:05 +08:00
|
|
|
|