Class: Policy::Base::Node Private

Inherits:
Object
  • Object
show all
Includes:
Policy::Base
Defined in:
lib/policy/base/node.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.

The base class for composite policies

Direct Known Subclasses

And, Not, Or, Xor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Policy::Base

#and, included, #or, #xor

Instance Attribute Details

#policiesArray<Policy::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 parts of the composite policy

Returns:



28
29
30
# File 'lib/policy/base/node.rb', line 28

def policies
  @policies
end

Class Method Details

.initialize(*policies) ⇒ 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 node (composite policy) from its parts

Parameters:

Returns:



20
21
22
# File 'lib/policy/base/node.rb', line 20

def initialize(*policies)
  @policies = policies
end

Instance Method Details

#new(*policies) ⇒ Policy::Base::Node

Creates the node (composite policy) from its parts

Parameters:

Returns:



20
21
22
# File 'lib/policy/base/node.rb', line 20

def initialize(*policies)
  @policies = policies
end

#valid?false

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.

This method is abstract.

Validates a composed policy and picks errors from its parts

Returns:

  • (false)


34
35
36
37
38
39
# File 'lib/policy/base/node.rb', line 34

def valid?
  errors.clear
  yield # returns true if a composition valid
  policies.each(&method(:pick_errors_from))
  false
end