Module: RestfulX::UUIDHelper
- Defined in:
- lib/restfulx/active_record_uuid_helper.rb
Overview
Extends ActiveRecord models with UUID based IDs
Class Method Summary collapse
Instance Method Summary collapse
-
#generate_uuid ⇒ Object
generates new UUID for the record.
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 |
# File 'lib/restfulx/active_record_uuid_helper.rb', line 6 def self.included(base) base.class_eval do before_create :generate_uuid end end |
Instance Method Details
#generate_uuid ⇒ Object
generates new UUID for the record
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 |