Skip to content

Commit

Permalink
Add ROM gem dependencies and relation class (#2)
Browse files Browse the repository at this point in the history
Bring in rom and rom-sql gem dependencies, and create a Hanami::DB::Relation class, which defaults to using the :sql adapter.
  • Loading branch information
timriley authored May 24, 2024
1 parent 371b9d2 commit 205a798
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hanami-db.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
}

spec.required_ruby_version = ">= 3.0.0"
spec.add_dependency "rom", "~> 5.3"
spec.add_dependency "rom-sql", "~> 3.6"
spec.add_dependency "zeitwerk", "~> 2.6"

spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
Expand Down
2 changes: 2 additions & 0 deletions lib/hanami/db.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "rom"
require "rom-sql"
require "zeitwerk"

module Hanami
Expand Down
10 changes: 10 additions & 0 deletions lib/hanami/db/relation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module Hanami
module DB
# @api public
# @since 2.2.0
class Relation < ROM::Relation[:sql]
end
end
end
9 changes: 9 additions & 0 deletions spec/unit/relation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

RSpec.describe Hanami::DB::Relation do
subject(:relation) { Class.new(described_class) }

it "defaults to the :sql adapter" do
expect(relation.adapter).to eq :sql
end
end

0 comments on commit 205a798

Please sign in to comment.