Module: LaunchDarkly::Impl::Model Private
- Defined in:
- lib/ldclient-rb/impl/model/clause.rb,
lib/ldclient-rb/impl/model/feature_flag.rb,
lib/ldclient-rb/impl/model/preprocessed_data.rb,
lib/ldclient-rb/impl/model/segment.rb,
lib/ldclient-rb/impl/model/serialization.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Clause, EvalResultFactoryMultiVariations, EvalResultsForSingleVariation, FeatureFlag, FlagRule, MigrationSettings, Preprocessor, Prerequisite, Rollout, Segment, SegmentRule, SegmentTarget, Target, VariationOrRollout, WeightedVariation
Class Method Summary collapse
-
.deserialize(kind, input, logger = nil) ⇒ Object
private
Abstraction of deserializing a feature flag or segment that was read from a data store or received from LaunchDarkly.
-
.make_all_store_data(received_data, logger = nil) ⇒ Object
private
Translates a { flags: ..., segments: ... } object received from LaunchDarkly to the data store format.
-
.serialize(kind, item) ⇒ Object
private
Abstraction of serializing a feature flag or segment that will be written to a data store.
Class Method Details
.deserialize(kind, input, logger = nil) ⇒ 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.
Abstraction of deserializing a feature flag or segment that was read from a data store or received from LaunchDarkly.
SDK code outside of Impl::Model should use this method instead of calling the model class constructors directly, so as not to rely on implementation details.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ldclient-rb/impl/model/serialization.rb', line 42 def self.deserialize(kind, input, logger = nil) return nil if input.nil? return input unless input.is_a?(String) || input.is_a?(Hash) data = input.is_a?(Hash) ? input : JSON.parse(input, symbolize_names: true) case kind when Impl::DataStore::FEATURES FeatureFlag.new(data, logger) when Impl::DataStore::SEGMENTS Segment.new(data, logger) else data end end |
.make_all_store_data(received_data, logger = nil) ⇒ 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.
Translates a { flags: ..., segments: ... } object received from LaunchDarkly to the data store format.
64 65 66 67 68 69 |
# File 'lib/ldclient-rb/impl/model/serialization.rb', line 64 def self.make_all_store_data(received_data, logger = nil) { Impl::DataStore::FEATURES => (received_data[:flags] || {}).transform_values { |data| FeatureFlag.new(data, logger) }, Impl::DataStore::SEGMENTS => (received_data[:segments] || {}).transform_values { |data| Segment.new(data, logger) }, } end |
.serialize(kind, item) ⇒ 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.
Abstraction of serializing a feature flag or segment that will be written to a data store. Currently we just call to_json, but SDK code outside of Impl::Model should use this method instead of to_json, so as not to rely on implementation details.
59 60 61 |
# File 'lib/ldclient-rb/impl/model/serialization.rb', line 59 def self.serialize(kind, item) item.to_json end |