rails / globalid

Identify app models with a URI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to limit how many times a sgid can be used?

edimossilva opened this issue · comments

Is there a way for doing something similar to what is described bellow?

user = User.create(params)
uid = user.to_sgid(access_count: 1).to_s
GlobalID::Locator.locate_signed(uid) # => returns user
GlobalID::Locator.locate_signed(uid) # => returns nil

You can implement you own locator that would keep track of the uid that it already saw, but I don't think you can embed that in the id itself.