Created
June 16, 2016 13:19
-
-
Save WaKeMaTTa/cee2b4e8e435f30bc32ad6e494caf93e to your computer and use it in GitHub Desktop.
app/serializers/hash_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/serializers/hash_serializer.rb | |
class HashSerializer | |
def self.dump(hash) | |
hash.to_json | |
end | |
def self.load(hash) | |
hash = ActiveSupport::JSON.decode(hash) if hash.is_a? String | |
(hash || {}).with_indifferent_access | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment