Module: UniqIdentifier::Hook

Defined in:
lib/uniq_identifier/hook.rb

Instance Method Summary collapse

Instance Method Details

#generate_uniq_identifier!Object



14
15
16
17
18
# File 'lib/uniq_identifier/hook.rb', line 14

def generate_uniq_identifier!
  if self.class.uniq_identifier_generator.respond_to?(:uuid)
    self.uuid = self.class.uniq_identifier_generator.uuid
  end
end

#set_uniq_identifierObject



10
11
12
# File 'lib/uniq_identifier/hook.rb', line 10

def set_uniq_identifier
  generate_uniq_identifier! if self.uuid.nil?
end

#uuid(*args, &block) ⇒ Object



5
6
7
8
# File 'lib/uniq_identifier/hook.rb', line 5

def uuid(*args, &block)
  generate_uniq_identifier! if super(*args, &block).nil?
  super
end