Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #12 from IFTTT/master

Added support for time-based UUIDs.
  • Loading branch information...
commit c992cbe05b27c4312a948b9d6fba822702c61821 2 parents 9a49401 + 29832dd
@jashmenn authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/activeuuid/uuid.rb
View
12 lib/activeuuid/uuid.rb
@@ -109,6 +109,11 @@ def uuid_attributes
@_activeuuid_attributes
end
+ def uuid_generator(generator_name=nil)
+ @_activeuuid_kind = generator_name if generator_name
+ @_activeuuid_kind || :random
+ end
+
def uuids(*attributes)
@_activeuuid_attributes = attributes.collect(&:intern).each do |attribute|
serialize attribute.intern, ActiveUUID::UUIDSerializer.new
@@ -127,7 +132,12 @@ def create_uuid
chained = nka.collect{|a| self.send(a).to_s}.join("-")
UUIDTools::UUID.sha1_create(UUIDTools::UUID_OID_NAMESPACE, chained)
else
- UUIDTools::UUID.random_create
+ case self.class.uuid_generator
+ when :random
+ UUIDTools::UUID.random_create
+ when :time
+ UUIDTools::UUID.timestamp_create
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.