Class: Cerbos::Output::PlanResources::Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/cerbos/output/plan_resources.rb

Overview

An abstract syntax tree node representing an expression to evaluate.

Defined Under Namespace

Classes: Value, Variable

Instance Attribute Summary collapse

Instance Attribute Details

#operandsArray<Expression, Value, Variable> (readonly)

The operands on which to invoke the operator.

Returns:


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cerbos/output/plan_resources.rb', line 73

PlanResources::Expression = Output.new_class(:operator, :operands) do
  # @!attribute [r] operator
  #   The operator to invoke.
  #
  #   @return [String]

  # @!attribute [r] operands
  #   The operands on which to invoke the operator.
  #
  #   @return [Array<Expression, Value, Variable>]

  def self.from_protobuf(expression)
    new(
      operator: expression.operator,
      operands: (expression.operands || []).map { |operand| PlanResources::Expression::Operand.from_protobuf(operand) }
    )
  end
end

#operatorString (readonly)

The operator to invoke.

Returns:

  • (String)

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cerbos/output/plan_resources.rb', line 73

PlanResources::Expression = Output.new_class(:operator, :operands) do
  # @!attribute [r] operator
  #   The operator to invoke.
  #
  #   @return [String]

  # @!attribute [r] operands
  #   The operands on which to invoke the operator.
  #
  #   @return [Array<Expression, Value, Variable>]

  def self.from_protobuf(expression)
    new(
      operator: expression.operator,
      operands: (expression.operands || []).map { |operand| PlanResources::Expression::Operand.from_protobuf(operand) }
    )
  end
end