Class: LaunchDarkly::Interfaces::DataSystem::Selector

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

Overview

Selector represents a particular snapshot of data.

This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning. It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state: "", version: 0) ⇒ Selector

Returns a new instance of Selector.

Parameters:

  • state (String) (defaults to: "")

    The state

  • version (Integer) (defaults to: 0)

    The version



112
113
114
115
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 112

def initialize(state: "", version: 0)
  @state = state
  @version = version
end

Instance Attribute Details

#stateString (readonly)

Returns The state.

Returns:

  • (String)

    The state



103
104
105
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 103

def state
  @state
end

#versionInteger (readonly)

Returns The version.

Returns:

  • (Integer)

    The version



106
107
108
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 106

def version
  @version
end

Class Method Details

.from_h(data) ⇒ Selector

Deserializes a Selector from a Hash.

Parameters:

  • data (Hash)

    The hash representation

Returns:

Raises:

  • (ArgumentError)

    if required fields are missing



174
175
176
177
178
179
180
181
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 174

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

  raise ArgumentError, "Missing required fields in Selector" if state.nil? || version.nil?

  Selector.new(state: state, version: version)
end

.new_selector(state, version) ⇒ Selector

Creates a new Selector from a state string and version.

Parameters:

  • state (String)

    The state

  • version (Integer)

    The version

Returns:



151
152
153
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 151

def self.new_selector(state, version)
  Selector.new(state: state, version: version)
end

.no_selectorSelector

Returns an empty Selector.

Returns:



122
123
124
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 122

def self.no_selector
  Selector.new
end

Instance Method Details

#==(other) ⇒ Object



183
184
185
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 183

def ==(other)
  other.is_a?(Selector) && @state == other.state && @version == other.version
end

#defined?Boolean

Returns true if the Selector has a value.

Returns:

  • (Boolean)


131
132
133
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 131

def defined?
  self != Selector.no_selector
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 187

def eql?(other)
  self == other
end

#hashObject



191
192
193
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 191

def hash
  [@state, @version].hash
end

#nameSymbol

Returns the event name for payload transfer.

Returns:

  • (Symbol)


140
141
142
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 140

def name
  EventName::PAYLOAD_TRANSFERRED
end

#to_hHash

Serializes the Selector to a Hash.

Returns:

  • (Hash)


160
161
162
163
164
165
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 160

def to_h
  {
    state: @state,
    version: @version,
  }
end