1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actiontext/lib/action_text/serialization.rb

35 lines
545 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module ActionText
2018-02-07 19:26:19 -05:00
module Serialization
extend ActiveSupport::Concern
class_methods do
def load(content)
new(content) if content
end
def dump(content)
case content
when nil
nil
when self
content.to_html
else
new(content).to_html
end
end
end
# Marshal compatibility
class_methods do
alias_method :_load, :load
end
def _dump(*)
self.class.dump(self)
end
end
end