Class: Twilic::Core::Model::Message
- Inherits:
-
Data
- Object
- Data
- Twilic::Core::Model::Message
- Defined in:
- lib/twilic/core/model.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#base_snapshot ⇒ Object
readonly
Returns the value of attribute base_snapshot.
-
#column_batch ⇒ Object
readonly
Returns the value of attribute column_batch.
-
#control ⇒ Object
readonly
Returns the value of attribute control.
-
#control_stream ⇒ Object
readonly
Returns the value of attribute control_stream.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#row_batch ⇒ Object
readonly
Returns the value of attribute row_batch.
-
#scalar ⇒ Object
readonly
Returns the value of attribute scalar.
-
#schema_object ⇒ Object
readonly
Returns the value of attribute schema_object.
-
#shaped_object ⇒ Object
readonly
Returns the value of attribute shaped_object.
-
#state_patch ⇒ Object
readonly
Returns the value of attribute state_patch.
-
#template_batch ⇒ Object
readonly
Returns the value of attribute template_batch.
-
#typed_vector ⇒ Object
readonly
Returns the value of attribute typed_vector.
Instance Method Summary collapse
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def array @array end |
#base_snapshot ⇒ Object (readonly)
Returns the value of attribute base_snapshot
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def base_snapshot @base_snapshot end |
#column_batch ⇒ Object (readonly)
Returns the value of attribute column_batch
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def column_batch @column_batch end |
#control ⇒ Object (readonly)
Returns the value of attribute control
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def control @control end |
#control_stream ⇒ Object (readonly)
Returns the value of attribute control_stream
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def control_stream @control_stream end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def ext @ext end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def kind @kind end |
#map ⇒ Object (readonly)
Returns the value of attribute map
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def map @map end |
#row_batch ⇒ Object (readonly)
Returns the value of attribute row_batch
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def row_batch @row_batch end |
#scalar ⇒ Object (readonly)
Returns the value of attribute scalar
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def scalar @scalar end |
#schema_object ⇒ Object (readonly)
Returns the value of attribute schema_object
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def schema_object @schema_object end |
#shaped_object ⇒ Object (readonly)
Returns the value of attribute shaped_object
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def shaped_object @shaped_object end |
#state_patch ⇒ Object (readonly)
Returns the value of attribute state_patch
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def state_patch @state_patch end |
#template_batch ⇒ Object (readonly)
Returns the value of attribute template_batch
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def template_batch @template_batch end |
#typed_vector ⇒ Object (readonly)
Returns the value of attribute typed_vector
244 245 246 |
# File 'lib/twilic/core/model.rb', line 244 def typed_vector @typed_vector end |
Instance Method Details
#clone_message ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/twilic/core/model.rb', line 249 def case kind when MessageKind::SCALAR v = scalar.clone_value Model.(kind: kind, scalar: v) when MessageKind::ARRAY Model.(kind: kind, array: array.map(&:clone_value)) when MessageKind::MAP Model.(kind: kind, map: map.map { |e| MessageMapEntry.new(e.key, e.value.clone_value) }) when MessageKind::SHAPED_OBJECT s = shaped_object vals = s.values.map(&:clone_value) pres = s.has_presence ? s.presence.dup : nil Model.(kind: kind, shaped_object: ShapedObjectMessage.new( shape_id: s.shape_id, presence: pres, has_presence: s.has_presence, values: vals )) when MessageKind::SCHEMA_OBJECT s = schema_object fields = s.fields.map(&:clone_value) pres = s.has_presence ? s.presence.dup : nil sid = s.schema_id Model.(kind: kind, schema_object: SchemaObjectMessage.new( schema_id: sid, presence: pres, has_presence: s.has_presence, fields: fields )) when MessageKind::TYPED_VECTOR Model.(kind: kind, typed_vector: Model.clone_typed_vector(typed_vector)) when MessageKind::ROW_BATCH rows = row_batch.rows.map { |r| r.map(&:clone_value) } Model.(kind: kind, row_batch: RowBatchMessage.new(rows: rows)) when MessageKind::COLUMN_BATCH cols = column_batch.columns.map { |c| Model.clone_column(c) } Model.(kind: kind, column_batch: ColumnBatchMessage.new( count: column_batch.count, columns: cols )) when MessageKind::CONTROL Model.(kind: kind, control: Model.clone_control(control)) when MessageKind::EXT Model.(kind: kind, ext: ExtMessage.new( ext_type: ext.ext_type, payload: ext.payload.b.dup )) when MessageKind::STATE_PATCH sp = state_patch ops = sp.operations.map do |op| val = op.value ? op.value.clone_value : nil PatchOperation.new(field_id: op.field_id, opcode: op.opcode, value: val) end lits = sp.literals.map(&:clone_value) Model.(kind: kind, state_patch: StatePatchMessage.new( base_ref: sp.base_ref, operations: ops, literals: lits )) when MessageKind::TEMPLATE_BATCH tb = template_batch cols = tb.columns.map { |c| Model.clone_column(c) } Model.(kind: kind, template_batch: TemplateBatchMessage.new( template_id: tb.template_id, count: tb.count, changed_column_mask: tb.changed_column_mask.dup, columns: cols )) when MessageKind::CONTROL_STREAM cs = control_stream Model.(kind: kind, control_stream: ControlStreamMessage.new( codec: cs.codec, payload: cs.payload.b.dup )) when MessageKind::BASE_SNAPSHOT bs = base_snapshot Model.(kind: kind, base_snapshot: BaseSnapshotMessage.new( base_id: bs.base_id, schema_or_shape_ref: bs.schema_or_shape_ref, payload: bs.payload. )) else Model.(kind: MessageKind::SCALAR) end end |