module UniqueId::Base
Public Instance Methods
generate_unique()
click to toggle source
# File lib/unique_id/base.rb, line 28 def generate_unique value = unique_format(self.class.unique.next(scope:self.unique_scope, type:self.unique_type)) write_attribute self.class.unique.attribute, value end
unique_format(value)
click to toggle source
# File lib/unique_id/base.rb, line 21 def unique_format(value) if f = self.class.unique.formatter return self.instance_exec(self.unique_scope, value, &f) end value end
unique_scope()
click to toggle source
# File lib/unique_id/base.rb, line 11 def unique_scope if scope = self.class.unique.scope @unique_scope ||= case scope when Symbol then self.send(scope) when Proc then self.instance_exec(&scope) else scope end end end
unique_type()
click to toggle source
# File lib/unique_id/base.rb, line 7 def unique_type self.class.to_s end