Class: Attestor::Policy::Negator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/attestor/policy/negator.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Composes a policy with an argument of its #not method

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#composerClass (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The the composer for policies

Returns:

  • (Class)


47
48
49
# File 'lib/attestor/policy/negator.rb', line 47

def composer
  @composer
end

#policyPolicy::Base (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The the policy to be composed with negations of other policies

Returns:

  • (Policy::Base)


41
42
43
# File 'lib/attestor/policy/negator.rb', line 41

def policy
  @policy
end

Class Method Details

.initialize(composer, policy) ⇒ Policy::Base::Negator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates the negator object, expecting #not method call

Parameters:

  • policy (Policy::Base)

    the policy to be composed with negations of other policies

  • composer (Class)

    the composer for policies

Returns:

  • (Policy::Base::Negator)


22
23
24
25
26
# File 'lib/attestor/policy/negator.rb', line 22

def initialize(composer, policy)
  @policy   = policy
  @composer = composer
  freeze
end

Instance Method Details

#new(policy, composer) ⇒ Policy::Base::Negator

Creates the negator object, expecting #not method call

Parameters:

  • policy (Policy::Base)

    the policy to be composed with negations of other policies

  • composer (Class)

    the composer for policies

Returns:

  • (Policy::Base::Negator)


22
23
24
25
26
# File 'lib/attestor/policy/negator.rb', line 22

def initialize(composer, policy)
  @policy   = policy
  @composer = composer
  freeze
end

#not(*policies) ⇒ Policy::Base

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a composition of the #policy with negations of other policies

Parameters:

  • policies (Policy::Base, Array<Policy::Base>)

Returns:

  • (Policy::Base)


33
34
35
# File 'lib/attestor/policy/negator.rb', line 33

def not(*policies)
  composer.new policy, policies.flat_map(&Not.method(:new))
end