Module: RestfulX::UUIDHelper

Defined in:
lib/restfulx/active_record_uuid_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
# File 'lib/restfulx/active_record_uuid_helper.rb', line 7

def self.included(base)
  base.class_eval do 
    before_create :generate_uuid
  end
end

Instance Method Details

#generate_uuidObject



13
14
15
# File 'lib/restfulx/active_record_uuid_helper.rb', line 13

def generate_uuid
  self.id = UUIDTools::UUID.random_create.to_s.gsub("-", "") unless self.id
end