Module: Diaspora::Guid

Included in:
Comment, Conversation, Federated::Relayable, Message, Person, Poll, PollAnswer, PollParticipation
Defined in:
lib/diaspora/guid.rb

Overview

implicitly requires roxml

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object

Creates a before_create callback which calls #set_guid and makes the guid serialize in to_xml


5
6
7
8
9
10
11
12
# File 'lib/diaspora/guid.rb', line 5

def self.included(model)
  model.class_eval do
    before_create :set_guid
    xml_attr :guid
    validates :guid, :uniqueness => true

  end
end

Instance Method Details

#set_guidString


15
16
17
# File 'lib/diaspora/guid.rb', line 15

def set_guid
  self.guid = UUID.generate :compact if self.guid.blank?
end