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 not suitable for production usage.
Do not use it. You have been warned.
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 ⇒ String
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.
130 131 132 133 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 130 def initialize(state: "", version: 0) @state = state @version = version end |
Instance Attribute Details
#state ⇒ String (readonly)
Returns The state.
121 122 123 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 121 def state @state end |
#version ⇒ Integer (readonly)
Returns The version.
124 125 126 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 124 def version @version end |
Class Method Details
.from_h(data) ⇒ Selector
Deserializes a Selector from a Hash.
192 193 194 195 196 197 198 199 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 192 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
201 202 203 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 201 def ==(other) other.is_a?(Selector) && @state == other.state && @version == other.version end |
#defined? ⇒ Boolean
Returns true if the Selector has a value.
149 150 151 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 149 def defined? self != Selector.no_selector end |
#eql?(other) ⇒ Boolean
205 206 207 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 205 def eql?(other) self == other end |
#hash ⇒ Object
209 210 211 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 209 def hash [@state, @version].hash end |
#name ⇒ String
Returns the event name for payload transfer.
158 159 160 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 158 def name EventName::PAYLOAD_TRANSFERRED end |
#to_h ⇒ Hash
Serializes the Selector to a Hash.
178 179 180 181 182 183 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 178 def to_h { state: @state, version: @version, } end |