Class: Prefab::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/prefab/options.rb

Overview

This class contains all the options that can be passed to the Prefab client.

Defined Under Namespace

Modules: DATASOURCES, ON_INITIALIZATION_FAILURE, ON_NO_DEFAULT

Constant Summary collapse

DEFAULT_MAX_PATHS =
1_000
DEFAULT_MAX_KEYS =
100_000
DEFAULT_MAX_EXAMPLE_CONTEXTS =
100_000
DEFAULT_MAX_EVAL_SUMMARIES =
100_000
DEFAULT_SOURCES =
[
  "https://belt.prefab.cloud",
  "https://suspenders.prefab.cloud",
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



144
145
146
# File 'lib/prefab/options.rb', line 144

def initialize(options = {})
  init(**options)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/prefab/options.rb', line 6

def api_key
  @api_key
end

#collect_sync_intervalObject (readonly)

Returns the value of attribute collect_sync_interval.



18
19
20
# File 'lib/prefab/options.rb', line 18

def collect_sync_interval
  @collect_sync_interval
end

#config_sourcesObject (readonly)

Returns the value of attribute config_sources.



11
12
13
# File 'lib/prefab/options.rb', line 11

def config_sources
  @config_sources
end

#datafileObject (readonly)

Returns the value of attribute datafile.



20
21
22
# File 'lib/prefab/options.rb', line 20

def datafile
  @datafile
end

#global_contextObject (readonly)

Returns the value of attribute global_context.



21
22
23
# File 'lib/prefab/options.rb', line 21

def global_context
  @global_context
end

#initialization_timeout_secObject (readonly)

Returns the value of attribute initialization_timeout_sec.



13
14
15
# File 'lib/prefab/options.rb', line 13

def initialization_timeout_sec
  @initialization_timeout_sec
end

#is_forkObject

Returns the value of attribute is_fork.



22
23
24
# File 'lib/prefab/options.rb', line 22

def is_fork
  @is_fork
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



7
8
9
# File 'lib/prefab/options.rb', line 7

def namespace
  @namespace
end

#on_init_failureObject (readonly)

Returns the value of attribute on_init_failure.



14
15
16
# File 'lib/prefab/options.rb', line 14

def on_init_failure
  @on_init_failure
end

#on_no_defaultObject (readonly)

Returns the value of attribute on_no_default.



12
13
14
# File 'lib/prefab/options.rb', line 12

def on_no_default
  @on_no_default
end

#prefab_config_classpath_dirObject (readonly)

Returns the value of attribute prefab_config_classpath_dir.



16
17
18
# File 'lib/prefab/options.rb', line 16

def prefab_config_classpath_dir
  @prefab_config_classpath_dir
end

#prefab_config_override_dirObject (readonly)

Returns the value of attribute prefab_config_override_dir.



15
16
17
# File 'lib/prefab/options.rb', line 15

def prefab_config_override_dir
  @prefab_config_override_dir
end

#prefab_envsObject (readonly)

Returns the value of attribute prefab_envs.



17
18
19
# File 'lib/prefab/options.rb', line 17

def prefab_envs
  @prefab_envs
end

#sourcesObject (readonly)

Returns the value of attribute sources.



8
9
10
# File 'lib/prefab/options.rb', line 8

def sources
  @sources
end

#sse_sourcesObject (readonly)

Returns the value of attribute sse_sources.



9
10
11
# File 'lib/prefab/options.rb', line 9

def sse_sources
  @sse_sources
end

#symbolize_json_namesObject (readonly)

Returns the value of attribute symbolize_json_names.



23
24
25
# File 'lib/prefab/options.rb', line 23

def symbolize_json_names
  @symbolize_json_names
end

#telemetry_destinationObject (readonly)

Returns the value of attribute telemetry_destination.



10
11
12
# File 'lib/prefab/options.rb', line 10

def telemetry_destination
  @telemetry_destination
end

#use_local_cacheObject (readonly)

Returns the value of attribute use_local_cache.



19
20
21
# File 'lib/prefab/options.rb', line 19

def use_local_cache
  @use_local_cache
end

Instance Method Details

#api_key_idObject



180
181
182
# File 'lib/prefab/options.rb', line 180

def api_key_id
  @api_key&.split("-")&.first
end

#collect_max_evaluation_summariesObject



174
175
176
177
178
# File 'lib/prefab/options.rb', line 174

def collect_max_evaluation_summaries
  return 0 unless telemetry_allowed?(@collect_evaluation_summaries)

  @collect_max_evaluation_summaries
end

#collect_max_example_contextsObject



168
169
170
171
172
# File 'lib/prefab/options.rb', line 168

def collect_max_example_contexts
  return 0 unless telemetry_allowed?(@collect_example_contexts)

  @collect_max_example_contexts
end

#collect_max_pathsObject



156
157
158
159
160
# File 'lib/prefab/options.rb', line 156

def collect_max_paths
  return 0 unless telemetry_allowed?(@collect_logger_counts)

  @collect_max_paths
end

#collect_max_shapesObject



162
163
164
165
166
# File 'lib/prefab/options.rb', line 162

def collect_max_shapes
  return 0 unless telemetry_allowed?(@collect_shapes)

  @collect_max_shapes
end

#datafile?Boolean

Returns:

  • (Boolean)


152
153
154
# File 'lib/prefab/options.rb', line 152

def datafile?
  !@datafile.nil?
end

#for_forkObject



184
185
186
187
188
# File 'lib/prefab/options.rb', line 184

def for_fork
  clone = self.clone
  clone.is_fork = true
  clone
end

#local_only?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/prefab/options.rb', line 148

def local_only?
  @prefab_datasources == DATASOURCES::LOCAL_ONLY
end