Sha256: f8489ce27f66e5c905ef523e893bdad4412aed6dc36c8258ee4452f862908ca4
Contents?: true
Size: 577 Bytes
Versions: 2
Compression:
Stored size: 577 Bytes
Contents
module ActsAsKeyed module InstanceMethods def to_param options[:as_param] ? self.key : self.id.to_s end def regenerate_key! self.create_key self.save end def key=(val) write_attribute(options[:column], val) end def key read_attribute(options[:column]) end protected def create_key k = nil 100.times do k = self.class.generate_key break if !self.class.key_exists?(k) k = nil end raise NoAvailableKeysError if k.nil? self.key = k end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
acts_as_keyed-1.0.0 | lib/acts_as_keyed/instance_methods.rb |
acts_as_keyed-0.1.3 | lib/acts_as_keyed/instance_methods.rb |