Module: RoadForest::SourceRigor::Credence

Defined in:
lib/roadforest/source-rigor/credence.rb,
lib/roadforest/source-rigor/credence/any.rb,
lib/roadforest/source-rigor/credence/role-if-available.rb,
lib/roadforest/source-rigor/credence/none-if-role-absent.rb

Defined Under Namespace

Classes: Any, NoneIfRoleAbsent, RoleIfAvailable

Class Method Summary collapse

Class Method Details

.policiesObject



3
4
5
6
7
8
9
10
11
# File 'lib/roadforest/source-rigor/credence.rb', line 3

def self.policies
  @policies ||= {
    :any => Any.new,
    :may_subject => RoleIfAvailable.new(:subject),
    :must_subject => NoneIfRoleAbsent.new(:subject),
    :may_local => RoleIfAvailable.new(:local),
    :must_local => NoneIfRoleAbsent.new(:local)
  }
end

.policy(name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/roadforest/source-rigor/credence.rb', line 13

def self.policy(name)
  if block_given?
    policies[name] ||= yield
  else
    begin
      policies.fetch(name)
    rescue KeyError
      raise "No Credence policy for #{name.inspect} (available named policies are #{policies.keys.inspect})"
    end
  end
end