Skip to content

Instantly share code, notes, and snippets.

@vovayartsev
Created April 12, 2013 10:10
Show Gist options
  • Save vovayartsev/5371017 to your computer and use it in GitHub Desktop.
Save vovayartsev/5371017 to your computer and use it in GitHub Desktop.
class Meeting < ActiveRecord::Base
serialize :metadata, MeetingMetadata::Coder
end
class MeetingMetadata
include Virtus
attribute :name, String
attribute :age, Integer
attribute :birthday, DateTime
module Coder
def self.load(string_value)
MeetingMetadata.new(JSON.parse(string_value || "{}"))
end
def self.dump(meeting_metadata)
meeting_metadata.to_json
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment