examples/role.rb in registrable-0.1.0 vs examples/role.rb in registrable-0.2.0

- old
+ new

@@ -1,24 +1,27 @@ require 'registrable' class Role + extend Registrable - def initialize(readable, modifiable) - @readable, @modifiable = readable, modifiable + def initialize(read, modify) + @read, @modify = read, modify end def readable? - @readable + @read end def modifiable? - @modifiable + @modify end + end class User + def initialize(role) self.role = role end attr_reader :role @@ -26,10 +29,11 @@ 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) +Role.register(:other, Role.new(false, false)) +Role.register(:user, Role.new(true, false)) +Role.register(:admin, Role.new(true, true))