README.rdoc in iq-acl-1.0.4 vs README.rdoc in iq-acl-1.0.5
- old
+ new
@@ -4,16 +4,21 @@
== Install
gem install iq-acl
== Usage
+ # Create an instance of the basic class, supplying rights as a hash, note
+ # that asterisks are used as wildcards.
auth = IQ::ACL::Basic.new({
'*' => { 'terry' => 'r' },
'projects' => { 'jonny' => 'rw' },
'projects/private' => { 'billy' => 'rw', 'terry' => nil },
'projects/public' => { 'terry' => 'rw', '*' => 'r' }
})
+
+ # You could alternatively read rights from a YAML file
+ auth = IQ::ACL::Basic.new(YAML.load_file('rights.yml'))
auth.authorize! 'guest', 'projects' #=> raises IQ::ACL::AccessDeniedError
auth.authorize! 'jonny', 'projects' #=> 'rw'
auth.authorize! 'billy', 'projects' #=> raises IQ::ACL::AccessDeniedError
auth.authorize! 'terry', 'projects' #=> 'r'
@@ -24,14 +29,14 @@
auth.authorize! 'guest', 'projects/public' #=> 'r'
auth.authorize! 'jonny', 'projects/public' #=> 'r'
auth.authorize! 'billy', 'projects/public' #=> 'r'
auth.authorize! 'terry', 'projects/public' #=> 'rw
- # A block may be given to <tt>authorize!</tt> that should return true if
- # the yielded rights are adequate for the user, for example the following
- # will raise an IQ::ACL::AccessDeniedError as 'terry' does not have write access
- # to the 'projects' path. If 'terry' had write access to the 'projects'
- # path, the exception would not be thrown.
+A block may be given to <tt>authorize!</tt> that should return true if
+the yielded rights are adequate for the user, for example the following
+will raise an IQ::ACL::AccessDeniedError as 'terry' does not have write access
+to the 'projects' path. If 'terry' had write access to the 'projects'
+path, the exception would not be thrown.
auth.authorize! 'terry', 'projects' do |rights|
rights.include?('w')
end