API
This page lists everything require "poli_page-rails" defines. Rails loads the gem from your Gemfile, so you rarely require it yourself. The RBS signatures ship in the gem’s sig/ folder. The client these helpers return is the Ruby SDK’s: see SDK.
PoliPage.client
Section titled “PoliPage.client”PoliPage.client # => PoliPage::ClientReturns the memoized SDK client. The first call validates Rails.application.config.poli_page and builds the client from to_client_kwargs. A Monitor makes the build thread-safe. Raises PoliPage::Rails::ConfigurationError when a setting is invalid.
PoliPage.reset_client!
Section titled “PoliPage.reset_client!”PoliPage.reset_client! # => nilClears the memoized client so the next PoliPage.client builds a new one. For specs only.
PoliPage::Rails::Renderable
Section titled “PoliPage::Rails::Renderable”render_pdf(bytes, filename: "document.pdf", inline: false)render_preview(result)redirect_to_document(descriptor, status: :found)A controller concern (ActiveSupport::Concern).
render_pdfsendsbyteswithContent-Type: application/pdf,Content-Dispositionencoded to RFC 5987 and RFC 6266 (inlineorattachment),Cache-Control: private, no-storeandX-Content-Type-Options: nosniff.render_previewrendersresult.html(orresult.to_swhen there is nohtml) astext/html; charset=utf-8, with the same two security headers.redirect_to_documentredirects todescriptor.presigned_pdf_urlwithCache-Control: private, no-store, and allows the other host.
See Responses.
PoliPage::Rails::Configuration
Section titled “PoliPage::Rails::Configuration”Rails.application.config.poli_page # => PoliPage::Rails::ConfigurationHolds the settings as attr_accessors: api_key, base_url, timeout, max_retries, retry_delay, logger, on_retry, on_error, proxy, ca_file, ca_path, notifications and error_handler. notifications and error_handler start true, the rest nil. to_client_kwargs returns the SDK client’s keyword arguments with every nil entry dropped, so the SDK’s defaults apply. See Configuration.
PoliPage::Rails::ConfigurationValidator
Section titled “PoliPage::Rails::ConfigurationValidator”PoliPage::Rails::ConfigurationValidator.validate!(config)Checks a Configuration and raises ConfigurationError on the first invalid value. PoliPage.client calls it. API_KEY_FORMAT is the pattern pp_{environment}_{32 lowercase hex} that drives the format warning. validate_error_handler!(value) is called by the Railtie at boot.
PoliPage::Rails::ConfigurationError
Section titled “PoliPage::Rails::ConfigurationError”class PoliPage::Rails::ConfigurationError < PoliPage::Error; endRaised for an invalid configuration. Its code is configuration_error and its status and request_id are nil.
PoliPage::Rails::ErrorHandler
Section titled “PoliPage::Rails::ErrorHandler”PoliPage::Rails::ErrorHandler.body(error) # => the error's to_payloadPoliPage::Rails::ErrorHandler.status(error) # => IntegerA controller concern that does rescue_from PoliPage::Error and renders the payload as JSON. status is the payload’s status, or 500 when it is nil. It raises the error again when the response is already committed. The Railtie includes it into ActionController::Base and ActionController::API unless error_handler is false. See Errors.
PoliPage::Rails::Notifications
Section titled “PoliPage::Rails::Notifications”PoliPage::Rails::Notifications::RETRY_EVENT_NAME # => "poli_page.retry"PoliPage::Rails::Notifications::ERROR_EVENT_NAME # => "poli_page.error"PoliPage::Rails::Notifications.retry_bridge # => lambdaPoliPage::Rails::Notifications.error_bridge # => lambdaThe two bridge lambdas are memoized. The Railtie installs them as the default on_retry and on_error when notifications is true. See Observability.
PoliPage::Rails::FilenameEncoder
Section titled “PoliPage::Rails::FilenameEncoder”PoliPage::Rails::FilenameEncoder.disposition(filename, inline:) # => StringBuilds a Content-Disposition value with ActionDispatch::Http::ContentDisposition.format, after removing control characters from filename. render_pdf uses it.
PoliPage::Rails::Engine and Railtie
Section titled “PoliPage::Rails::Engine and Railtie”class PoliPage::Rails::Engine < ::Rails::Engine; endclass PoliPage::Rails::Railtie < ::Rails::Railtie; endThe engine is isolated in the PoliPage::Rails namespace. The Railtie sets Rails.application.config.poli_page before the initializers in config/initializers run, includes the error handler after them, and in after_initialize defaults logger to Rails.logger and installs the notification bridges.
PoliPage::Rails::VERSION
Section titled “PoliPage::Rails::VERSION”PoliPage::Rails::VERSION # => "0.13.1"The gem version.
Generator
Section titled “Generator”bin/rails generate poli_page:installWrites config/initializers/poli_page.rb, a commented template of every setting. It takes no options of its own.
SDK types
Section titled “SDK types”The gem does not re-export the SDK. PoliPage::Error and its subclasses, PoliPage::RetryEvent and the client come from the poli-page gem, which require "poli_page-rails" loads.