Class: Cel::Message
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Cel::Message
- Defined in:
- lib/cel/ast/elements.rb
Instance Attribute Summary collapse
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #field?(key) ⇒ Boolean
-
#initialize(type, struct) ⇒ Message
constructor
A new instance of Message.
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
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
26 27 28 |
# File 'lib/cel/ast/elements.rb', line 26 def struct @struct end |
#type ⇒ Object (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
36 37 38 |
# File 'lib/cel/ast/elements.rb', line 36 def field?(key) !@type.get(key).nil? end |