Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Bitmask
ACTIONS = %W(create read update destroy)
def self.dump(actions)
(actions & ACTIONS).sum { |a| 1 << ACTIONS.index(a) }
end
def self.load(mask)
ACTIONS.reject { |a| ((mask || 0) & 1 << ACTIONS.index(a)).zero? }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.