Sha256: 4f172293a22a80e283a292c74afc57e675feb5ba9e770b276e4ae483229e72c0
Contents?: true
Size: 551 Bytes
Versions: 1
Compression:
Stored size: 551 Bytes
Contents
require 'registrable' class Role extend Registrable def initialize(readable, modifiable) @readable, @modifiable = readable, modifiable end def readable? @readable end def modifiable? @modifiable end end class User def initialize(role) self.role = role end attr_reader :role def role=(role) role = Role.registry[role] || Role.registry[:other] unless role.is_a?(Role) @role = role end end Role.register(:other, false, false) Role.register(:user, true, false) Role.register(:admin, true, true)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
registrable-0.1.0 | examples/role.rb |