Module: GlobalUid::ActiveRecordExtension

Defined in:
lib/global_uid/active_record_extension.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
# File 'lib/global_uid/active_record_extension.rb', line 5

def self.included(base)
  base.extend(ClassMethods)
  base.before_create :global_uid_before_create
end

Instance Method Details

#global_uid_before_createObject



10
11
12
13
14
15
# File 'lib/global_uid/active_record_extension.rb', line 10

def global_uid_before_create
  return if GlobalUid.disabled?
  return if self.class.global_uid_disabled

  self.id = self.class.generate_uid
end