Class: LaunchDarkly::Impl::Model::FeatureFlag Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::Model::FeatureFlag
- Defined in:
- lib/ldclient-rb/impl/model/feature_flag.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
- #context_targets ⇒ Array<LaunchDarkly::Impl::Model::Target> readonly private
- #data ⇒ Hash readonly private
- #deleted ⇒ Boolean readonly private
- #exclude_from_summaries ⇒ Boolean? readonly private
- #fallthrough ⇒ LaunchDarkly::Impl::Model::VariationOrRollout readonly private
- #fallthrough_results ⇒ LaunchDarkly::Impl::Model::EvalResultFactoryMultiVariations readonly private
- #key ⇒ String readonly private
- #migration_settings ⇒ MigrationSettings? readonly private
- #off_result ⇒ LaunchDarkly::EvaluationDetail readonly private
- #off_variation ⇒ Integer|nil readonly private
- #on ⇒ Boolean readonly private
- #prerequisites ⇒ Array<LaunchDarkly::Impl::Model::Prerequisite> readonly private
- #rules ⇒ Array<LaunchDarkly::Impl::Model::FlagRule> readonly private
- #salt ⇒ String readonly private
- #sampling_ratio ⇒ Integer? readonly private
- #targets ⇒ Array<LaunchDarkly::Impl::Model::Target> readonly private
- #variations ⇒ Array 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 ⇒ FeatureFlag
private
Returns a shallow copy of this flag that carries the override marker.
-
#initialize(data, logger = nil) ⇒ FeatureFlag
constructor
private
A new instance of FeatureFlag.
-
#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) ⇒ FeatureFlag
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 FeatureFlag.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 21 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 migration_settings = data[:migration] || {} @migration_settings = MigrationSettings.new(migration_settings[:checkRatio]) @sampling_ratio = data[:samplingRatio] @exclude_from_summaries = !!data[:excludeFromSummaries] @variations = data[:variations] || [] @on = !!data[:on] fallthrough = data[:fallthrough] || {} @fallthrough = VariationOrRollout.new(fallthrough[:variation], fallthrough[:rollout], self, errors, "fallthrough") @off_variation = data[:offVariation] check_variation_range(self, errors, @off_variation, "off variation") @prerequisites = (data[:prerequisites] || []).map do |prereq_data| Prerequisite.new(prereq_data, self) end @targets = (data[:targets] || []).map do |target_data| Target.new(target_data, self, errors) end @context_targets = (data[:contextTargets] || []).map do |target_data| Target.new(target_data, self, errors) end @rules = (data[:rules] || []).map.with_index do |rule_data, index| FlagRule.new(rule_data, index, self, errors) end @salt = data[:salt] @off_result = EvaluatorHelpers.evaluation_detail_for_off_variation(self, EvaluationReason::off) @fallthrough_results = Preprocessor.precompute_multi_variation_results(self, EvaluationReason::fallthrough(false), EvaluationReason::fallthrough(true)) unless logger.nil? errors.each do || logger.error("[LDClient] Data inconsistency in feature flag \"#{@key}\": #{}") end end end |
Instance Attribute Details
#context_targets ⇒ Array<LaunchDarkly::Impl::Model::Target> (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.
94 95 96 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 94 def context_targets @context_targets end |
#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.
64 65 66 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 64 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.
70 71 72 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 70 def deleted @deleted end |
#exclude_from_summaries ⇒ 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.
76 77 78 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 76 def exclude_from_summaries @exclude_from_summaries end |
#fallthrough ⇒ LaunchDarkly::Impl::Model::VariationOrRollout (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.
84 85 86 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 84 def fallthrough @fallthrough end |
#fallthrough_results ⇒ LaunchDarkly::Impl::Model::EvalResultFactoryMultiVariations (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.
88 89 90 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 88 def fallthrough_results @fallthrough_results 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.
66 67 68 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 66 def key @key end |
#migration_settings ⇒ MigrationSettings? (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.
72 73 74 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 72 def migration_settings @migration_settings end |
#off_result ⇒ LaunchDarkly::EvaluationDetail (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.
86 87 88 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 86 def off_result @off_result end |
#off_variation ⇒ 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.
82 83 84 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 82 def off_variation @off_variation end |
#on ⇒ 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.
80 81 82 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 80 def on @on end |
#prerequisites ⇒ Array<LaunchDarkly::Impl::Model::Prerequisite> (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.
90 91 92 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 90 def prerequisites @prerequisites end |
#rules ⇒ Array<LaunchDarkly::Impl::Model::FlagRule> (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.
96 97 98 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 96 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.
98 99 100 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 98 def salt @salt end |
#sampling_ratio ⇒ 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.
74 75 76 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 74 def sampling_ratio @sampling_ratio end |
#targets ⇒ Array<LaunchDarkly::Impl::Model::Target> (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.
92 93 94 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 92 def targets @targets end |
#variations ⇒ Array (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.
78 79 80 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 78 def variations @variations 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.
68 69 70 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 68 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.
136 137 138 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 136 def ==(other) other.is_a?(FeatureFlag) && 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.
132 133 134 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 132 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
140 141 142 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 140 def as_json(*) # parameter is unused, but may be passed if we're using the json gem @data end |
#as_override ⇒ FeatureFlag
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 flag that carries the override marker. The copy shares its data with this flag. Nothing writes to that data. This flag is not changed.
Flag overrides are currently experimental and subject to change.
123 124 125 126 127 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 123 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 flag 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.
111 112 113 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 111 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.
145 146 147 |
# File 'lib/ldclient-rb/impl/model/feature_flag.rb', line 145 def to_json(*a) as_json.to_json(*a) end |