Class: Umpire::Policy

Inherits:
Object
  • Object
show all
Includes:
AuthHelper
Defined in:
lib/umpire/policy.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AuthHelper

#can?

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/umpire/policy.rb', line 25

def self.allows? subject
  new subject
end

Instance Method Details

#rulesObject

overwrite me

Raises:



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