Class: Authorization::DevelopmentSupport::AnalyzerEngine::Privilege
- Inherits:
-
Object
- Object
- Authorization::DevelopmentSupport::AnalyzerEngine::Privilege
- Defined in:
- lib/declarative_authorization/development_support/development_support.rb
Constant Summary collapse
- @@privilege_objects =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#ancestors(priv_symbol = nil) ⇒ Object
Ancestor privileges are higher in the hierarchy.
- #descendants(priv_symbol = nil) ⇒ Object
-
#initialize(privilege, engine) ⇒ Privilege
constructor
A new instance of Privilege.
- #rules ⇒ Object
- #source_file ⇒ Object
- #source_line ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(privilege, engine) ⇒ Privilege
Returns a new instance of Privilege.
162 163 164 165 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 162 def initialize (privilege, engine) @privilege = privilege @engine = engine end |
Class Method Details
.for_sym(privilege_sym, engine) ⇒ Object
197 198 199 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 197 def self.for_sym (privilege_sym, engine) @@privilege_objects[[privilege_sym, engine]] ||= new(privilege_sym, engine) end |
Instance Method Details
#ancestors(priv_symbol = nil) ⇒ Object
Ancestor privileges are higher in the hierarchy. Doesn’t take context into account.
169 170 171 172 173 174 175 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 169 def ancestors (priv_symbol = nil) priv_symbol ||= @privilege # context-specific? (@engine.rev_priv_hierarchy[[priv_symbol, nil]] || []). collect {|higher_priv| ancestors(higher_priv) }.flatten + (priv_symbol == @privilege ? [] : [Privilege.for_sym(priv_symbol, @engine)]) end |
#descendants(priv_symbol = nil) ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 176 def descendants (priv_symbol = nil) priv_symbol ||= @privilege # context-specific? (@engine.privilege_hierarchy[priv_symbol] || []). collect {|lower_priv, context| descendants(lower_priv) }.flatten + (priv_symbol == @privilege ? [] : [Privilege.for_sym(priv_symbol, @engine)]) end |
#rules ⇒ Object
184 185 186 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 184 def rules @rules ||= find_rules_for_privilege end |
#source_file ⇒ Object
190 191 192 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 190 def source_file rules.empty? ? nil : rules.first.source_file end |
#source_line ⇒ Object
187 188 189 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 187 def source_line rules.empty? ? nil : rules.first.source_line end |
#to_sym ⇒ Object
194 195 196 |
# File 'lib/declarative_authorization/development_support/development_support.rb', line 194 def to_sym @privilege end |