| Class | Authorization::Reader::PrivilegesReader |
| In: |
lib/reader.rb
|
| Parent: | Object |
The PrivilegeReader handles the part of the authorization DSL in a privileges block. Here, privilege hierarchies are defined.
Specifies privileges that are to be assigned as lower ones. Only to be used inside a privilege block.
# File lib/reader.rb, line 122
122: def includes (*privileges)
123: raise DSLError, "includes only in privilege block" if @current_priv.nil?
124: privileges.each do |priv|
125: append_privilege priv
126: @privilege_hierarchy[@current_priv] ||= []
127: @privilege_hierarchy[@current_priv] << [priv, @current_context]
128: end
129: end
Defines part of a privilege hierarchy. For the given privilege, included privileges may be defined in the block (through includes) or as option :includes. If the optional context is given, the privilege hierarchy is limited to that context.
# File lib/reader.rb, line 105
105: def privilege (privilege, context = nil, options = {}, &block)
106: if context.is_a?(Hash)
107: options = context
108: context = nil
109: end
110: @current_priv = privilege
111: @current_context = context
112: append_privilege privilege
113: instance_eval(&block) if block
114: includes(*options[:includes]) if options[:includes]
115: ensure
116: @current_priv = nil
117: @current_context = nil
118: end