diaspora/lib/diaspora/guid.rb
Jonne Haß 01e0127287 Ignore embedded photos if invalid
For example if they're already present
Also refactor StatusMessage XML specs
2014-09-06 04:52:18 +02:00

18 lines
435 B
Ruby

#implicitly requires roxml
module Diaspora::Guid
# Creates a before_create callback which calls #set_guid and makes the guid serialize in to_xml
def self.included(model)
model.class_eval do
after_initialize :set_guid
xml_attr :guid
validates :guid, :uniqueness => true
end
end
# @return [String] The model's guid.
def set_guid
self.guid = UUID.generate :compact if self.guid.blank?
end
end