Class: RubyACL::ACLBasicList

Inherits:
ACLType
  • Object
show all
Defined in:
lib/rubyacl.rb

Overview

A simple ACL that checks for the existence of an identifier on a list

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ACLBasicList

data may be an Array or a String. If it is a String it is assumed to be a filename containing one entry per line.



244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/rubyacl.rb', line 244

def initialize(data)
	if(data.kind_of?(String))
		File.open(data, File::RDONLY) { |fp| 
			data = fp.readlines.map() { |line| line.strip() } 
		}
	end
	
	@list = Hash.new()
	data.each() { |entry| 
		@list[entry] = true
	}
end

Class Method Details

.acltypeObject



237
238
239
# File 'lib/rubyacl.rb', line 237

def ACLBasicList.acltype()
	return('basiclist')
end

Instance Method Details

#check(context) ⇒ Object

checks context against the list



259
260
261
262
263
264
265
# File 'lib/rubyacl.rb', line 259

def check(context)
	if(@list.has_key?(context[:identifier]))
		return(true)
	end
		
	return(false)
end