# File lib/pretty_id.rb, line 10 def self.primary_key 'id' end
module PrettyId
Constants
- VERSION
Public Class Methods
primary_key()
click to toggle source
Public Instance Methods
_create_record(*)
click to toggle source
Calls superclass method
# File lib/pretty_id.rb, line 35 def _create_record(*) attempt ||= 1 set_pretty_id super rescue ActiveRecord::RecordNotUnique => e attempt += 1 retry if attempt < 4 raise end
id_prefix()
click to toggle source
# File lib/pretty_id.rb, line 22 def id_prefix @id_prefix || name.downcase[0, 3] end
id_prefix=(prefix)
click to toggle source
# File lib/pretty_id.rb, line 18 def id_prefix=(prefix) @id_prefix = prefix end
id_separator()
click to toggle source
# File lib/pretty_id.rb, line 30 def id_separator @id_separator end
id_separator=(separator)
click to toggle source
# File lib/pretty_id.rb, line 26 def id_separator=(separator) @id_separator = separator end
Private Instance Methods
set_pretty_id()
click to toggle source
# File lib/pretty_id.rb, line 48 def set_pretty_id self.id = PrettyId::Generator.new(self).id end