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.
-
#initialize(data, logger = nil) ⇒ Segment
constructor
private
A new instance of Segment.
-
#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 |
# 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] 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.
44 45 46 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 44 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.
50 51 52 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 50 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.
54 55 56 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 54 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.
58 59 60 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 58 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.
66 67 68 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 66 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.
52 53 54 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 52 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.
56 57 58 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 56 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.
46 47 48 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 46 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.
60 61 62 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 60 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.
68 69 70 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 68 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.
62 63 64 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 62 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.
64 65 66 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 64 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.
48 49 50 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 48 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.
77 78 79 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 77 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.
73 74 75 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 73 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
81 82 83 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 81 def as_json(*) # parameter is unused, but may be passed if we're using the json gem @data 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.
86 87 88 |
# File 'lib/ldclient-rb/impl/model/segment.rb', line 86 def to_json(*a) as_json.to_json(*a) end |