Permalink
Browse files

Monkey patch UUID class to add #next method (generate another random …

…UUID)
  • Loading branch information...
1 parent f712b2f commit 5677bb96d2247d924c0c1cea91e232400cd0e86f @thomasguillory thomasguillory committed Apr 25, 2013
Showing with 5 additions and 0 deletions.
  1. +4 −0 lib/activeuuid/uuid.rb
  2. +1 −0 spec/lib/uuid_mokeypatch_spec.rb
View
@@ -8,6 +8,10 @@ class UUID
# duck typing activerecord 3.1 dirty hack )
def gsub *; self; end
+ def next
+ self.class.random_create
+ end
+
def quoted_id
s = raw.unpack("H*")[0]
"x'#{s}'"
@@ -12,6 +12,7 @@
its(:quoted_id) {should == sql_out}
its(:as_json) {should == hex}
its(:to_param) {should == hex}
+ its(:next) {should be_a(described_class)}
end
describe '.serialize' do

0 comments on commit 5677bb9

Please sign in to comment.