Class: LaunchDarkly::Impl::DataStore::DataKind

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/data_store.rb

Overview

Since:

  • 5.5.0

Constant Summary collapse

FEATURES =

Since:

  • 5.5.0

"features".freeze
SEGMENTS =

Since:

  • 5.5.0

"segments".freeze
FEATURE_PREREQ_FN =

Since:

  • 5.5.0

lambda { |flag| (flag[:prerequisites] || []).map { |p| p[:key] } }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace:, priority:) ⇒ DataKind

Returns a new instance of DataKind.

Parameters:

  • namespace (String)
  • priority (Integer)

Since:

  • 5.5.0



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

#namespaceObject (readonly)

Since:

  • 5.5.0



14
15
16
# File 'lib/ldclient-rb/impl/data_store.rb', line 14

def namespace
  @namespace
end

#priorityObject (readonly)

Since:

  • 5.5.0



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.

Parameters:

  • key (Symbol)

Returns:

  • (Object)

Since:

  • 5.5.0



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

Returns:

  • (Boolean)

Since:

  • 5.5.0



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_fnObject

Retrieve the dependency keys for a particular data kind. Right now, this is only defined for flags.

Since:

  • 5.5.0



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

#hashObject

Since:

  • 5.5.0



52
53
54
# File 'lib/ldclient-rb/impl/data_store.rb', line 52

def hash
  [namespace, priority].hash
end