Class: LaunchDarkly::Interfaces::DataSystem::ServerIntent

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/interfaces/data_system.rb

Overview

ServerIntent represents the type of change associated with the payload.

This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is not suitable for production usage.

Do not use it. You have been warned.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload:) ⇒ ServerIntent

Returns a new instance of ServerIntent.

Parameters:

  • payload (Payload)

    The payload



403
404
405
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 403

def initialize(payload:)
  @payload = payload
end

Instance Attribute Details

#payloadPayload (readonly)

Returns The payload.

Returns:



398
399
400
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 398

def payload
  @payload
end

Class Method Details

.from_h(data) ⇒ ServerIntent

Deserializes a ServerIntent from a Hash.

Parameters:

  • data (Hash)

    The hash representation

Returns:

Raises:

  • (ArgumentError)

    if required fields are missing or invalid



425
426
427
428
429
430
431
432
433
434
435
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 425

def self.from_h(data)
  payloads = data['payloads'] || data[:payloads]

  raise ArgumentError, "Invalid data for ServerIntent: 'payloads' key is missing or not an array" unless payloads.is_a?(Array)
  raise ArgumentError, "Invalid data for ServerIntent: expected exactly one payload" unless payloads.length == 1

  payload = payloads[0]
  raise ArgumentError, "Invalid payload in ServerIntent: expected a hash" unless payload.is_a?(Hash)

  ServerIntent.new(payload: Payload.from_h(payload))
end

Instance Method Details

#to_hHash

Serializes the ServerIntent to a Hash.

Returns:

  • (Hash)


412
413
414
415
416
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 412

def to_h
  {
    payloads: [@payload.to_h],
  }
end