Namespace

Class/Module Index [+]

Quicksearch

UIDAttribute

UIDAttribute version

Constants

VERSION

Public Instance Methods

set_uid click to toggle source

set :uid_attribute

# File lib/uid_attribute.rb, line 61
def set_uid
  klass = self.class
  has_uid_accessors?

  uid = klass.uid_object ?  UUIDTools::UUID.md5_create(UUIDTools::UUID_OID_NAMESPACE, self.inspect) :
    UUIDTools::UUID.random_create.to_s

  send("#{klass.uid_attr}=", uid)
end

Protected Instance Methods

has_uid_accessors? click to toggle source

raises errors unless the including class has a setter and getter for Klass.uid_attr

# File lib/uid_attribute.rb, line 78
def has_uid_accessors?
  klass = self.class
  uid_attr = klass.uid_attr
  raise "dev.error: #{klass}.respond_to?(:#{uid_attr}) == false" unless respond_to?(uid_attr)
  raise "dev.error: #{klass}.respond_to?(:#{uid_attr}=) == false" unless respond_to?("#{uid_attr}=")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.