Class: Hipaapotamus::Policy
- Inherits:
-
Object
- Object
- Hipaapotamus::Policy
- Defined in:
- lib/hipaapotamus/policy.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#protected ⇒ Object
readonly
Returns the value of attribute protected.
Class Method Summary collapse
Instance Method Summary collapse
- #access? ⇒ Boolean
- #authorize!(action) ⇒ Object
- #authorized?(action) ⇒ Boolean
- #creation? ⇒ Boolean
- #destruction? ⇒ Boolean
-
#initialize(agent, protected) ⇒ Policy
constructor
A new instance of Policy.
- #modification? ⇒ Boolean
Constructor Details
#initialize(agent, protected) ⇒ Policy
Returns a new instance of Policy.
7 8 9 |
# File 'lib/hipaapotamus/policy.rb', line 7 def initialize(agent, protected) @agent, @protected = agent, protected end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
5 6 7 |
# File 'lib/hipaapotamus/policy.rb', line 5 def agent @agent end |
#protected ⇒ Object (readonly)
Returns the value of attribute protected.
5 6 7 |
# File 'lib/hipaapotamus/policy.rb', line 5 def protected @protected end |
Class Method Details
.authorize!(agent, protected, action) ⇒ Object
36 37 38 |
# File 'lib/hipaapotamus/policy.rb', line 36 def (agent, protected, action) new(agent, protected).(action) end |
Instance Method Details
#access? ⇒ Boolean
23 24 25 |
# File 'lib/hipaapotamus/policy.rb', line 23 def access? false end |
#authorize!(action) ⇒ Object
15 16 17 |
# File 'lib/hipaapotamus/policy.rb', line 15 def (action) (action) || raise(AccountabilityError, "#{agent.hipaapotamus_display_name} does not have #{action} privileges to #{protected.hipaapotamus_display_name}") end |
#authorized?(action) ⇒ Boolean
11 12 13 |
# File 'lib/hipaapotamus/policy.rb', line 11 def (action) SystemAgent === agent || try(:"#{action}?") end |
#creation? ⇒ Boolean
19 20 21 |
# File 'lib/hipaapotamus/policy.rb', line 19 def creation? false end |
#destruction? ⇒ Boolean
31 32 33 |
# File 'lib/hipaapotamus/policy.rb', line 31 def destruction? false end |
#modification? ⇒ Boolean
27 28 29 |
# File 'lib/hipaapotamus/policy.rb', line 27 def modification? false end |