Class: LaunchDarkly::Impl::DataStore::DataKind
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::DataStore::DataKind
- Defined in:
- lib/ldclient-rb/impl/data_store.rb
Overview
Constant Summary collapse
- FEATURES =
"features".freeze
- SEGMENTS =
"segments".freeze
- FEATURE_PREREQ_FN =
lambda { |flag| (flag[:prerequisites] || []).map { |p| p[:key] } }.freeze
Instance Attribute Summary collapse
- #namespace ⇒ Object readonly
- #priority ⇒ Object readonly
Instance Method Summary collapse
-
#[](key) ⇒ Object
Maintain the same behavior when these data kinds were standard ruby hashes.
- #eql?(other) ⇒ Boolean
-
#get_dependency_keys_fn ⇒ Object
Retrieve the dependency keys for a particular data kind.
- #hash ⇒ Object
-
#initialize(namespace:, priority:) ⇒ DataKind
constructor
A new instance of DataKind.
Constructor Details
#initialize(namespace:, priority:) ⇒ DataKind
Returns a new instance of DataKind.
21 22 23 24 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 21 def initialize(namespace:, priority:) @namespace = namespace @priority = priority end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
14 15 16 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 14 def namespace @namespace end |
#priority ⇒ Object (readonly)
15 16 17 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 15 def priority @priority end |
Instance Method Details
#[](key) ⇒ Object
Maintain the same behavior when these data kinds were standard ruby hashes.
32 33 34 35 36 37 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 32 def [](key) return priority if key == :priority return namespace if key == :namespace return get_dependency_keys_fn() if key == :get_dependency_keys nil end |
#eql?(other) ⇒ Boolean
48 49 50 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 48 def eql?(other) other.is_a?(DataKind) && namespace == other.namespace && priority == other.priority end |
#get_dependency_keys_fn ⇒ Object
Retrieve the dependency keys for a particular data kind. Right now, this is only defined for flags.
42 43 44 45 46 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 42 def get_dependency_keys_fn() return nil unless @namespace == FEATURES FEATURE_PREREQ_FN end |
#hash ⇒ Object
52 53 54 |
# File 'lib/ldclient-rb/impl/data_store.rb', line 52 def hash [namespace, priority].hash end |