Class: Policy::Base::Not Private

Inherits:
Node
  • Object
show all
Defined in:
lib/policy/base/not.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.

Negation of given policy

It is invalid when given policy is valid. Doesn’t add any #errors.

Examples:

negation = Policy::Base::Not.new(some_policy)
some_policy.valid? # => true
negation.valid?    # => false

Instance Attribute Summary

Attributes inherited from Node

#policies

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Policy::Base

#and, included, #or, #xor

Class Method Details

.initialize(_) ⇒ Policy::Base::Node

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 policy negation

Parameters:

Returns:



22
23
24
# File 'lib/policy/base/not.rb', line 22

def initialize(_)
  super
end

Instance Method Details

#new(policy) ⇒ Policy::Base::Node

Creates the policy negation

Parameters:

Returns:



22
23
24
# File 'lib/policy/base/not.rb', line 22

def initialize(_)
  super
end

#valid?Boolean

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.

Checks whether negated policy is invalid

Examples:

negation = Policy::Base::Not.new(some_policy)
some_policy.valid? # => true
negation.valid?    # => false

Returns:

  • (Boolean)


34
35
36
# File 'lib/policy/base/not.rb', line 34

def valid?
  super { return true if any_invalid? }
end