Introducing Berm

Hi! I made this little library to experiment with macros, it’s a little library that lets you manage permissions.

Any comment or review is really appreciated!

3 Likes

Whats the benefit over just using a Flags Enum?

https://play.crystal-lang.org/#/r/97sk

@[Flags]
enum MyFlags
  Read
  Write
  
  ReadWrite = Read | Write
end
 
pp MyFlags::Read.read?       # => true
pp MyFlags::Write.read?      # => false
pp MyFlags::ReadWrite.read?  # => true
pp MyFlags::ReadWrite.write? # => true
pp MyFlags::None.write?      # => false
pp MyFlags::All.write?       # => true

(cross post from Reddit)

Actually none, I suppose. I’m new to Crystal, didn’t know about all the capabilities of flag enums and I wanted to experiment with macros. I build this object in python for work purposes and decided to reproduce in crystal, playing with ci and shards to learn something new ans I wanted to provide a really simple way to make an object for manage permissions. At lest this could be the base code where more useful features can be built upon

2 Likes