Class: RailsAiBridge::Introspectors::TimezoneIntrospector
- Inherits:
-
Object
- Object
- RailsAiBridge::Introspectors::TimezoneIntrospector
- Defined in:
- lib/rails_ai_bridge/introspectors/timezone_introspector.rb
Overview
Extracts timezone configuration from the host Rails application.
Reads config.time_zone and compares it with Time.zone (which Rails
sets at boot from config.time_zone) to emit structured facts. This
applies to every Rails app regardless of stack, so it always runs as
part of ConfigIntrospector; it is not a preset-gated section.
Instance Attribute Summary collapse
-
#app ⇒ Rails::Application
readonly
Host Rails application.
Instance Method Summary collapse
-
#call ⇒ Hash
Builds timezone facts.
-
#initialize(app) ⇒ TimezoneIntrospector
constructor
A new instance of TimezoneIntrospector.
Constructor Details
#initialize(app) ⇒ TimezoneIntrospector
Returns a new instance of TimezoneIntrospector.
22 23 24 |
# File 'lib/rails_ai_bridge/introspectors/timezone_introspector.rb', line 22 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Rails::Application (readonly)
Returns host Rails application.
19 20 21 |
# File 'lib/rails_ai_bridge/introspectors/timezone_introspector.rb', line 19 def app @app end |
Instance Method Details
#call ⇒ Hash
Builds timezone facts. Time.zone is set by Rails at boot from
config.time_zone. Confirmation compares IANA identifiers so Rails
names and their IANA identifiers agree. An unavailable or
different runtime zone leaves the configured value unconfirmed.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_ai_bridge/introspectors/timezone_introspector.rb', line 32 def call configured = app.config.time_zone.to_s runtime_identifier = Time.zone&.tzinfo&.identifier { time_zone: configured, time_zone_confirmed: (runtime_identifier && runtime_identifier == ActiveSupport::TimeZone[configured]&.tzinfo&.identifier) || false } rescue StandardError => error { error: error. } end |