Class: LaunchDarkly::Impl::Model::Segment Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::Model::Segment
- Defined in:
- lib/ldclient-rb/impl/model/segment.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #data ⇒ Hash readonly private
- #deleted ⇒ Boolean readonly private
- #excluded ⇒ Array<String> readonly private
- #excluded_contexts ⇒ Array<LaunchDarkly::Impl::Model::SegmentTarget> readonly private
- #generation ⇒ Integer|nil readonly private
- #included ⇒ Array<String> readonly private
- #included_contexts ⇒ Array<LaunchDarkly::Impl::Model::SegmentTarget> readonly private
- #key ⇒ String readonly private
- #rules ⇒ Array<SegmentRule> readonly private
- #salt ⇒ String readonly private
- #unbounded ⇒ Boolean readonly private
- #unbounded_context_kind ⇒ String readonly private
- #version ⇒ Integer readonly private
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#[](key) ⇒ Object
private
This method allows us to read properties of the object as if it's just a hash.
-
#as_json ⇒ Object
private
parameter is unused, but may be passed if we're using the json gem.
-
#as_override ⇒ Segment
private
Returns a shallow copy of this segment that carries the override marker.
-
#initialize(data, logger = nil) ⇒ Segment
constructor
private
A new instance of Segment.
-
#override? ⇒ Boolean
private
True if this definition came from the SDK's override store rather than from LaunchDarkly data.
-
#to_json(*a) ⇒ Object
private
Same as as_json, but converts the JSON structure into a string.
Constructor Details
#initialize(data, logger = nil) ⇒ Segment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Segment.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 13 def initialize(data, logger = nil) raise ArgumentError, "expected hash but got #{data.class}" unless data.is_a?(Hash) errors = [] @data = data @key = data[:key] @version = data[:version] @deleted = !!data[:deleted] @override = false return if @deleted @included = data[:included] || [] @excluded = data[:excluded] || [] @included_contexts = (data[:includedContexts] || []).map do |target_data| SegmentTarget.new(target_data) end @excluded_contexts = (data[:excludedContexts] || []).map do |target_data| SegmentTarget.new(target_data) end @rules = (data[:rules] || []).map do |rule_data| SegmentRule.new(rule_data, errors) end @unbounded = !!data[:unbounded] @unbounded_context_kind = data[:unboundedContextKind] || LDContext::KIND_DEFAULT @generation = data[:generation] @salt = data[:salt] unless logger.nil? errors.each do || logger.error("[LDClient] Data inconsistency in segment \"#{@key}\": #{}") end end end |
Instance Attribute Details
#data ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 45 def data @data end |
#deleted ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 51 def deleted @deleted end |
#excluded ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 55 def excluded @excluded end |
#excluded_contexts ⇒ Array<LaunchDarkly::Impl::Model::SegmentTarget> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 59 def excluded_contexts @excluded_contexts end |
#generation ⇒ Integer|nil (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 67 def generation @generation end |
#included ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 53 def included @included end |
#included_contexts ⇒ Array<LaunchDarkly::Impl::Model::SegmentTarget> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 57 def included_contexts @included_contexts end |
#key ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 47 def key @key end |
#rules ⇒ Array<SegmentRule> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 61 def rules @rules end |
#salt ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 69 def salt @salt end |
#unbounded ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 63 def unbounded @unbounded end |
#unbounded_context_kind ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 65 def unbounded_context_kind @unbounded_context_kind end |
#version ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 49 def version @version end |
Instance Method Details
#==(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 107 def ==(other) other.is_a?(Segment) && other.data == self.data end |
#[](key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method allows us to read properties of the object as if it's just a hash. Currently this is necessary because some data store logic is still written to expect hashes; we can remove it once we migrate entirely to using attributes of the class.
103 104 105 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 103 def [](key) @data[key] end |
#as_json ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
parameter is unused, but may be passed if we're using the json gem
111 112 113 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 111 def as_json(*) # parameter is unused, but may be passed if we're using the json gem @data end |
#as_override ⇒ Segment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a shallow copy of this segment that carries the override marker. The copy shares its data with this segment. Nothing writes to that data. This segment is not changed.
Flag overrides are currently experimental and subject to change.
94 95 96 97 98 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 94 def as_override copy = dup copy.override = true copy end |
#override? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
True if this definition came from the SDK's override store rather than from LaunchDarkly data. The marker is not part of the segment data and is never serialized. Only the SDK components that manage override entries set it, through #as_override. Evaluation reads it to mark the evaluations it affects. Every other reader treats a marked definition the same as any other.
Flag overrides are currently experimental and subject to change.
82 83 84 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 82 def override? @override end |
#to_json(*a) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Same as as_json, but converts the JSON structure into a string.
116 117 118 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 116 def to_json(*a) as_json.to_json(*a) end |