Class: Umpire::Policy
- Inherits:
-
Object
- Object
- Umpire::Policy
- Includes:
- AuthHelper
- Defined in:
- lib/umpire/policy.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(subject) ⇒ Policy
constructor
A new instance of Policy.
-
#rules ⇒ Object
overwrite me.
- #to(actions, object = nil) ⇒ Object
Methods included from AuthHelper
Constructor Details
#initialize(subject) ⇒ Policy
Returns a new instance of Policy.
21 22 23 |
# File 'lib/umpire/policy.rb', line 21 def initialize subject @subject = subject end |
Class Method Details
.allows?(subject) ⇒ Boolean
25 26 27 |
# File 'lib/umpire/policy.rb', line 25 def self.allows? subject new subject end |
Instance Method Details
#rules ⇒ Object
overwrite me
36 37 38 |
# File 'lib/umpire/policy.rb', line 36 def rules raise NoRulesFound.new("Please implement `rules` in your policy object") end |
#to(actions, object = nil) ⇒ Object
29 30 31 32 33 |
# File 'lib/umpire/policy.rb', line 29 def to actions, object = nil @object = object @actions = *actions @actions.all? { |a| rules.include?(a) } end |