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.
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.
94 95 96 97 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 94 def initialize(state: "", version: 0) @state = state @version = version end |
Instance Attribute Details
#state ⇒ String (readonly)
Returns The state.
85 86 87 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 85 def state @state end |
#version ⇒ Integer (readonly)
Returns The version.
88 89 90 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 88 def version @version end |
Class Method Details
.from_h(data) ⇒ Selector
Deserializes a Selector from a Hash.
156 157 158 159 160 161 162 163 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 156 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
165 166 167 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 165 def ==(other) other.is_a?(Selector) && @state == other.state && @version == other.version end |
#defined? ⇒ Boolean
Returns true if the Selector has a value.
113 114 115 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 113 def defined? self != Selector.no_selector end |
#eql?(other) ⇒ Boolean
169 170 171 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 169 def eql?(other) self == other end |
#hash ⇒ Object
173 174 175 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 173 def hash [@state, @version].hash end |
#name ⇒ Symbol
Returns the event name for payload transfer.
122 123 124 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 122 def name EventName::PAYLOAD_TRANSFERRED end |
#to_h ⇒ Hash
Serializes the Selector to a Hash.
142 143 144 145 146 147 |
# File 'lib/ldclient-rb/interfaces/data_system.rb', line 142 def to_h { state: @state, version: @version, } end |