Class: LaunchDarkly::Interfaces::DataSystem::Selector
- Inherits:
-
Object
- Object
- LaunchDarkly::Interfaces::DataSystem::Selector
- 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
-
#state ⇒ String
readonly
The state.
-
#version ⇒ Integer
readonly
The version.
Class Method Summary collapse
-
.from_h(data) ⇒ Selector
Deserializes a Selector from a Hash.
-
.new_selector(state, version) ⇒ Selector
Creates a new Selector from a state string and version.
-
.no_selector ⇒ Selector
Returns an empty Selector.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#defined? ⇒ Boolean
Returns true if the Selector has a value.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(state: "", version: 0) ⇒ Selector
constructor
A new instance of Selector.
-
#name ⇒ Symbol
Returns the event name for payload transfer.
-
#to_h ⇒ Hash
Serializes the Selector to a Hash.
Constructor Details
#initialize(state: "", version: 0) ⇒ Selector
Returns a new instance of Selector.
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
#state ⇒ String (readonly)
Returns The state.
103 104 105 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 103 def state @state end |
#version ⇒ Integer (readonly)
Returns 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.
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 |
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.
131 132 133 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 131 def defined? self != Selector.no_selector end |
#eql?(other) ⇒ Boolean
187 188 189 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 187 def eql?(other) self == other end |
#hash ⇒ Object
191 192 193 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 191 def hash [@state, @version].hash end |
#name ⇒ Symbol
Returns the event name for payload transfer.
140 141 142 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 140 def name EventName::PAYLOAD_TRANSFERRED end |
#to_h ⇒ Hash
Serializes the Selector to a 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 |