2014-09-25 02:45:35 +08:00
|
|
|
class SiteTextSerializer < ApplicationSerializer
|
2016-04-01 05:33:25 +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
|
2016-04-01 05:33:25 +08:00
|
|
|
object[:id]
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
|
|
|
|
2016-04-01 05:33:25 +08:00
|
|
|
def value
|
|
|
|
object[:value]
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
|
|
|
|
2016-04-01 05:33:25 +08:00
|
|
|
def overridden?
|
|
|
|
current_val = value
|
2014-09-25 02:45:35 +08:00
|
|
|
|
2016-04-01 05:33:25 +08:00
|
|
|
I18n.overrides_disabled do
|
|
|
|
return I18n.t(object[:id]) != current_val
|
|
|
|
end
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
|
|
|
|
2016-04-01 05:33:25 +08:00
|
|
|
alias_method :can_revert?, :overridden?
|
2014-09-25 02:45:35 +08:00
|
|
|
end
|
2016-04-01 05:33:25 +08:00
|
|
|
|