Sha256: 666669bc07499720607013ba24f6d3b038946c9648692b4a61c464b36e80785a
Contents?: true
Size: 500 Bytes
Versions: 1
Compression:
Stored size: 500 Bytes
Contents
require "active_support/concern" module WithUuid module Model extend ActiveSupport::Concern included do self.primary_key = :id before_validation :set_id before_create :set_id end protected def set_id return unless id.blank? uuid = WithUuid::CombUuid.uuid.to_s before_set_id( uuid ) write_attribute( :id, uuid ) after_set_id( uuid ) end def before_set_id( uuid ); end def after_set_id( uuid ); end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
with_uuid-0.3.0 | lib/with_uuid/model.rb |