Created
April 12, 2013 10:10
-
-
Save vovayartsev/5371017 to your computer and use it in GitHub Desktop.
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
class Meeting < ActiveRecord::Base | |
serialize :metadata, MeetingMetadata::Coder | |
end |
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
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