RolifyCommunity / rolify

Role management library with resource scoping
https://rolifycommunity.github.io/rolify/
MIT License
3.16k stars 404 forks source link

Adding an expired date #563

Closed KuroBayashi closed 3 years ago

KuroBayashi commented 3 years ago

Hi, I would like to know if there is a way to add an "expired_at" field to the relation between User and Role ? Couldn't find any information about something like this.

So I could do something like :

room = Chat::Room.find(1)

sarah = User.find(1)
david = User.find(2)

# Today
sarah.add_role :muted, room, 7.days.from_now
david.add_role :muted, room

sarah.has_role? :muted, room     # should return true
david.has_role? :muted, room     # should return true

# A week later
sarah.has_role? :muted, room    # should return false
david.has_role? :muted, room    # should return true

Thanks.

KuroBayashi commented 3 years ago

Close the issue due to no longer use this gems.