Class: Quonfig::BoundClient

Inherits:
Object
  • Object
show all
Defined in:
lib/quonfig/bound_client.rb

Overview

Immutable context-bound view over a Quonfig::Client. Every lookup uses the bound context as the jit_context passed down to the resolver.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, context) ⇒ BoundClient

Returns a new instance of BoundClient.



9
10
11
12
13
# File 'lib/quonfig/bound_client.rb', line 9

def initialize(client, context)
  @client = client
  @context = context || {}
  freeze
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/quonfig/bound_client.rb', line 7

def client
  @client
end

#contextObject (readonly)

Returns the value of attribute context.



7
8
9
# File 'lib/quonfig/bound_client.rb', line 7

def context
  @context
end

Instance Method Details

#enabled?(feature_name) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/quonfig/bound_client.rb', line 69

def enabled?(feature_name)
  @client.enabled?(feature_name, @context)
end

#get_bool(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



27
28
29
# File 'lib/quonfig/bound_client.rb', line 27

def get_bool(key, default: NO_DEFAULT_PROVIDED)
  @client.get_bool(key, default: default, context: @context)
end

#get_bool_details(key) ⇒ Object

—- Details getters ———————————————-



45
46
47
# File 'lib/quonfig/bound_client.rb', line 45

def get_bool_details(key)
  @client.get_bool_details(key, context: @context)
end

#get_duration(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



35
36
37
# File 'lib/quonfig/bound_client.rb', line 35

def get_duration(key, default: NO_DEFAULT_PROVIDED)
  @client.get_duration(key, default: default, context: @context)
end

#get_float(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



23
24
25
# File 'lib/quonfig/bound_client.rb', line 23

def get_float(key, default: NO_DEFAULT_PROVIDED)
  @client.get_float(key, default: default, context: @context)
end

#get_float_details(key) ⇒ Object



57
58
59
# File 'lib/quonfig/bound_client.rb', line 57

def get_float_details(key)
  @client.get_float_details(key, context: @context)
end

#get_int(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



19
20
21
# File 'lib/quonfig/bound_client.rb', line 19

def get_int(key, default: NO_DEFAULT_PROVIDED)
  @client.get_int(key, default: default, context: @context)
end

#get_int_details(key) ⇒ Object



53
54
55
# File 'lib/quonfig/bound_client.rb', line 53

def get_int_details(key)
  @client.get_int_details(key, context: @context)
end

#get_json(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



39
40
41
# File 'lib/quonfig/bound_client.rb', line 39

def get_json(key, default: NO_DEFAULT_PROVIDED)
  @client.get_json(key, default: default, context: @context)
end

#get_json_details(key) ⇒ Object



65
66
67
# File 'lib/quonfig/bound_client.rb', line 65

def get_json_details(key)
  @client.get_json_details(key, context: @context)
end

#get_string(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



15
16
17
# File 'lib/quonfig/bound_client.rb', line 15

def get_string(key, default: NO_DEFAULT_PROVIDED)
  @client.get_string(key, default: default, context: @context)
end

#get_string_details(key) ⇒ Object



49
50
51
# File 'lib/quonfig/bound_client.rb', line 49

def get_string_details(key)
  @client.get_string_details(key, context: @context)
end

#get_string_list(key, default: NO_DEFAULT_PROVIDED) ⇒ Object



31
32
33
# File 'lib/quonfig/bound_client.rb', line 31

def get_string_list(key, default: NO_DEFAULT_PROVIDED)
  @client.get_string_list(key, default: default, context: @context)
end

#get_string_list_details(key) ⇒ Object



61
62
63
# File 'lib/quonfig/bound_client.rb', line 61

def get_string_list_details(key)
  @client.get_string_list_details(key, context: @context)
end

#in_context(additional) ⇒ Object

Returns a new BoundClient whose bound context is the merge of this bound context and additional. Merge is one level deep per named context (mirrors sdk-node’s mergeContexts): later values override earlier within the same named context; keys unique to each side are preserved.



78
79
80
# File 'lib/quonfig/bound_client.rb', line 78

def in_context(additional)
  self.class.new(@client, merge_contexts(@context, additional || {}))
end

#inspectObject



82
83
84
# File 'lib/quonfig/bound_client.rb', line 82

def inspect
  "#<Quonfig::BoundClient context=#{@context.inspect}>"
end