Class: LaunchDarkly::Impl::ContextFilter

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

Overview

Since:

  • 5.5.0

Instance Method Summary collapse

Constructor Details

#initialize(all_attributes_private, private_attributes) ⇒ ContextFilter

Returns a new instance of ContextFilter.

Parameters:

  • all_attributes_private (Boolean)
  • private_attributes (Array<String>)

Since:

  • 5.5.0



8
9
10
11
12
13
14
15
16
# File 'lib/ldclient-rb/impl/context_filter.rb', line 8

def initialize(all_attributes_private, private_attributes)
  @all_attributes_private = all_attributes_private

  @private_attributes = []
  private_attributes.each do |attribute|
    reference = LaunchDarkly::Reference.create(attribute)
    @private_attributes << reference if reference.error.nil?
  end
end

Instance Method Details

#filter(context) ⇒ Hash

Return a hash representation of the provided context with attribute redaction applied.

Parameters:

Returns:

  • (Hash)

Since:

  • 5.5.0



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ldclient-rb/impl/context_filter.rb', line 25

def filter(context)
  return filter_single_context(context, true) unless context.multi_kind?

  filtered = {kind: 'multi'}
  (0...context.individual_context_count).each do |i|
    c = context.individual_context(i)
    next if c.nil?

    filtered[c.kind] = filter_single_context(c, false)
  end

  filtered
end