Module: BetterAuth::Telemetry::Options
- Defined in:
- lib/better_auth/telemetry/options.rb,
lib/better_auth/telemetry/options.rb
Overview
Value objects that normalize the heterogeneous shapes the ‘BetterAuth::Telemetry.create(options, context)` entry point accepts into the small, well-typed surface the rest of the pipeline depends on.
Two normalizers ship together:
-
NormalizedOptions wraps the host-supplied ‘options`. The argument may be a Configuration, a raw `Hash`, or `nil`.
-
NormalizedContext wraps the optional ‘context` hash that callers use to override telemetry-side detection (`custom_track`, `database`, `adapter`, `skip_test_check`).
Both accept either snake_case (‘:custom_track`, `:skip_test_check`, `:database`, `:adapter`) or camelCase (`:customTrack`, `:skipTestCheck`) keys, in either symbol or string form, so callers mirroring the upstream TypeScript API do not have to translate keys by hand.
Neither value object raises on missing or ‘nil` input. Missing keys surface as `nil` readers (or `false` for the boolean-defaulting `skip_test_check`).
Class Method Summary collapse
-
.fetch_key(hash, snake, camel) ⇒ Object?
Look up a key in a hash, accepting symbol and string forms of both the snake_case and camelCase variants.
Class Method Details
.fetch_key(hash, snake, camel) ⇒ Object?
Look up a key in a hash, accepting symbol and string forms of both the snake_case and camelCase variants. Returns ‘nil` when nothing matches; an explicit `nil` value also returns `nil`.
229 230 231 232 233 234 235 236 237 |
# File 'lib/better_auth/telemetry/options.rb', line 229 def self.fetch_key(hash, snake, camel) return nil unless hash.is_a?(Hash) keys = [snake, camel, snake.to_s, camel.to_s].uniq keys.each do |key| return hash[key] if hash.key?(key) end nil end |