Skip to content
Snippets Groups Projects
Commit cae83c2b authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

serialize metadata attributes

parent d3f5989a
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
module Metadatable module Metadatable
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do
serialize :metadata, HashSerializer
end
def get_metadata_value_of key def get_metadata_value_of key
get_metadata_values_of(key).first get_metadata_values_of(key).first
end end
......
class HashSerializer
def self.dump(hash)
hash.to_json
end
def self.load(hash)
(hash || {}).with_indifferent_access
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment