Class: Irc::Bot::Auth::PermissionSet
- Inherits:
- 
      Object
      
        - Object
- Irc::Bot::Auth::PermissionSet
 
- Defined in:
- /home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb
Overview
This class describes a permission set
Instance Attribute Summary (collapse)
- 
  
    
      - (Object) perm 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute perm. 
Instance Method Summary (collapse)
- 
  
    
      - (PermissionSet) initialize 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Create a new (empty) PermissionSet. 
- 
  
    
      - (Object) inspect 
    
    
  
  
  
  
  
  
  
  
  
    Inspection simply inspects the internal hash. 
- 
  
    
      - (Boolean) permit?(str) 
    
    
  
  
  
  
  
  
  
  
  
    Tells if command cmd is permitted. 
- 
  
    
      - (Object) reset_permission(cmd) 
    
    
  
  
  
  
  
  
  
  
  
    Resets the permission for command cmd. 
- 
  
    
      - (Object) set_permission(str, val) 
    
    
  
  
  
  
  
  
  
  
  
    Sets the permission for command cmd to val,. 
Constructor Details
- (PermissionSet) initialize
Create a new (empty) PermissionSet
| 150 151 152 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 150 def initialize @perm = {} end | 
Instance Attribute Details
- (Object) perm (readonly)
Returns the value of attribute perm
| 147 148 149 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 147 def perm @perm end | 
Instance Method Details
- (Object) inspect
Inspection simply inspects the internal hash
| 155 156 157 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 155 def inspect @perm.inspect end | 
- (Boolean) permit?(str)
Tells if command cmd is permitted. We do this by returning the value of the deepest Command#path that matches.
| 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 182 def permit?(str) cmd = str.to_irc_auth_command # TODO user-configurable list of always-allowed commands, # for admins that want to set permissions -* for everybody return true if cmd.command == :login allow = nil cmd.path.reverse.each { |k| if @perm.has_key?(k) allow = @perm[k] break end } return allow end | 
- (Object) reset_permission(cmd)
Resets the permission for command cmd
| 175 176 177 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 175 def (cmd) (cmd, nil) end | 
- (Object) set_permission(str, val)
Sets the permission for command cmd to val,
| 161 162 163 164 165 166 167 168 169 170 171 | # File '/home/apoc/projects/ruby/rbot/lib/rbot/botuser.rb', line 161 def (str, val) cmd = str.to_irc_auth_command case val when true, false @perm[cmd.command] = val when nil @perm.delete(cmd.command) else raise TypeError, "#{val.inspect} must be true or false" unless [true,false].include?(val) end end |