Class: Cel::Message

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/cel/ast/elements.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, struct) ⇒ Message

Returns a new instance of Message.



28
29
30
31
32
33
34
# File 'lib/cel/ast/elements.rb', line 28

def initialize(type, struct)
  @struct = Struct.new(*struct.keys.map(&:to_sym)).new(*struct.values)
  @type = type.is_a?(Type) ? type : MapType.new(struct.to_h do |k, v|
                                                  [Literal.to_cel_type(k), Literal.to_cel_type(v)]
                                                end)
  super(@struct)
end

Instance Attribute Details

#structObject (readonly)

Returns the value of attribute struct.



26
27
28
# File 'lib/cel/ast/elements.rb', line 26

def struct
  @struct
end

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/cel/ast/elements.rb', line 26

def type
  @type
end

Instance Method Details

#field?(key) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/cel/ast/elements.rb', line 36

def field?(key)
  !@type.get(key).nil?
end