Class: Sinatra::Base
- Inherits:
-
Object
- Object
- Sinatra::Base
- Defined in:
- lib/htm/integrations/sinatra.rb
Class Method Summary collapse
-
.register_htm ⇒ Object
Register HTM with Sinatra application.
Class Method Details
.register_htm ⇒ Object
Register HTM with Sinatra application
Automatically configures HTM for Sinatra apps:
-
Adds helpers
-
Adds middleware
-
Configures logger
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/htm/integrations/sinatra.rb', line 168 def self.register_htm helpers HTM::Sinatra::Helpers use HTM::Sinatra::Middleware # Configure HTM with Sinatra logger HTM.configure do |config| config.logger = logger if respond_to?(:logger) # Use Sidekiq if available, otherwise thread-based config.job.backend = if defined?(::Sidekiq) :sidekiq else :thread end end # Establish initial connection (Sequel handles pooling automatically) begin HTM::Sinatra::Middleware.store_config! HTM::SequelConfig.establish_connection! HTM.logger.info "HTM database connection established" rescue StandardError => e HTM.logger.error "Failed to establish HTM database connection: #{e.}" raise end HTM.logger.info "HTM registered with Sinatra application" end |