Sha256: 6abd0e0f1c377d1160aebe9ac65501e65d9e67acaa9394aadf22900c5ad60d5a
Contents?: true
Size: 695 Bytes
Versions: 2
Compression:
Stored size: 695 Bytes
Contents
module MadID module IdentityMethods extend ActiveSupport::Concern module UrlMethods def to_param self.identifier end end included do before_create :set_identifier attr_readonly :identifier def self.object_identifier_prefix @identifier end end def set_identifier self.identifier = "#{self.class.object_identifier_prefix}-#{SecureRandom.uuid}"[0..34].downcase end def short_identifier self.identifier[0..11] end def identifier=(value) write_attribute(self.class.mad_id_column, value) end def identifier read_attribute(self.class.mad_id_column) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mad_id-1.1.1 | lib/mad_id/identity_methods.rb |
mad_id-1.1.0 | lib/mad_id/identity_methods.rb |