Skip to content

Add Opal database payload loader#65

Open
suleman-uzair wants to merge 2 commits intomainfrom
fix/opal-database-payload-loader
Open

Add Opal database payload loader#65
suleman-uzair wants to merge 2 commits intomainfrom
fix/opal-database-payload-loader

Conversation

@suleman-uzair
Copy link
Copy Markdown
Member

Adds an explicit Unitsml::Unitsdb::Database.load_opal_payload hook for Opal builds.

This lets downstream packages provide the bundled UnitsDB payload without generating subclasses or reimplementing from_db. The Opal loader remains owned by unitsml-ruby, including the missing-payload error path.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated Opal-only hook to inject a bundled UnitsDB payload at runtime, allowing Opal consumers to use Unitsml::Unitsdb::Database.from_db without subclassing or re-implementing loading behavior.

Changes:

  • Add Unitsml::Unitsdb::Database.load_opal_payload and opal_payload helpers to support injected payloads (with fallback to the DATABASE constant).
  • Update Opal from_db path to use the new opal_payload accessor and raise when missing.
  • Extend specs to cover the new Opal payload injection behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/unitsml/unitsdb/database.rb Introduces load_opal_payload/opal_payload and switches Opal loading to use the payload accessor.
spec/unitsml/unitsdb/database_spec.rb Resets Opal payload between examples and adds coverage for the new payload injection hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/unitsml/unitsdb/database.rb Outdated
Comment thread spec/unitsml/unitsdb/database_spec.rb Outdated
@suleman-uzair suleman-uzair marked this pull request as ready for review April 27, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants