class

Berm::Flag

Inherits Reference < Object

Flag is the permission manager.

It loads permission values from the variable pointed out by the FlagsConstant annotation, otherwise from FlagValues and raises a compilation error if there's none of the above. This variable has to be an array of symbols or strings, starting with the capital letter.

It stores the values in The enum PermValues using powers of two as values, which make easy to combine multiple permissions.

For each permission value happens the following:

  • the value is added to PermValues
  • the representation of the value as a Flag object is saved as class constant using the same name
  • a method permits_{value}? is generated telling if that permission is enabled NOTE: value, here, is converted in snake case.

A None constant with PermValues::None is generated to be the zero-value. A permits_something? method is added to tell if there's at least one permission enabled

Macros

build_consts
build_permission_requests
init_values