Module: UniversalIdentifiable

Defined in:
lib/universal_identifiable.rb,
lib/universal_identifiable/version.rb

Constant Summary collapse

NAMESPACER =

sample uuid: ‘hotel.ritz’ TODO: store underscored modelname as prefix automatically. e.G. ‘#modelname.ritz’ when assigning attribute

"."
VERSION =
"0.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

def self.included(base)
  base.validates :uuid, :presence => true, :uniqueness => true
end

Instance Method Details

#uuid(options = {}) ⇒ Object



14
15
16
17
# File 'lib/universal_identifiable.rb', line 14

def uuid(options={})
  options[:namespaced] = true if options[:namespaced].nil?
  options[:namespaced] ? read_attribute(:uuid) : short_uuid
end