Class: Attestor::Policy::Node

Inherits:
Object
  • Object
show all
Includes:
Attestor::Policy, Enumerable
Defined in:
lib/attestor/policy/node.rb

Direct Known Subclasses

And, Not, Or, Xor

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attestor::Policy

#and, included, new, #not, #or, #xor

Methods included from Validations::ClassMethods

#validate, #validates, #validations, #validators

Methods included from Factory

#and, #not, #or, #xor

Methods included from Validations

included, #invalid, #validate

Constructor Details

#initialize(*branches) ⇒ Node

Returns a new instance of Node.



13
14
15
16
# File 'lib/attestor/policy/node.rb', line 13

def initialize(*branches)
  @branches = branches.flatten
  freeze
end

Instance Attribute Details

#branchesObject (readonly)

Returns the value of attribute branches.



11
12
13
# File 'lib/attestor/policy/node.rb', line 11

def branches
  @branches
end

Instance Method Details

#eachObject



22
23
24
# File 'lib/attestor/policy/node.rb', line 22

def each
  block_given? ? branches.each { |item| yield(item.validate) } : to_enum
end

#validate!Object



18
19
20
# File 'lib/attestor/policy/node.rb', line 18

def validate!
  invalid :base
end