Sha256: 4ad159ebe8d0ffd3014f0134c1302cfc6cea55bbff0445da4a23522ac3b36be5
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
# New API interface for CBAC system # # Changelog # 101022 Bert Meerman Initial commit # module Cbac # Starts a privileges and privilegeset declaration block def cbac(&block) # Defines a new privilegeset def set(name, description, &block) # Adds a post declaration def post(controller, *methods) raise "Cannot add privilege without a set" unless @current_set_name methods.each {|method| Privilege.resource @current_set_name, @cbac_namespace.to_s + controller.to_s + "/" + method.to_s, :post } end # Adds a get declaration def get(controller, *methods) raise "Cannot add privilege without a set" unless @current_set_name methods.each {|method| Privilege.resource @current_set_name, @cbac_namespace.to_s + controller.to_s + "/" + method.to_s, :get } end # Includes the stuff from another set def includes(*set) raise "includes is not yet supported" end raise "Cannot embed a set in another set" if @current_set name = name.to_sym description = description.to_str PrivilegeSet.add(name, description) @current_set = PrivilegeSet.sets[name] @current_set_name = name yield block @current_set = nil @current_set_name = nil end # Start an additional namespace declaration def in_module (name, &block) current_namespace = @cbac_namespace @cbac_namespace = @cbac_namespace.to_s + name.to_s + "/" yield block @cbac_namespace = current_namespace end # Runs the block yield block end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cbac-0.6.3 | lib/cbac/privilege_new_api.rb |
cbac-0.6.1 | lib/cbac/privilege_new_api.rb |
cbac-0.6.0 | lib/cbac/privilege_new_api.rb |