Skip to content

Commit

Permalink
Alias ruby gem loadable_path to to_path
Browse files Browse the repository at this point in the history
The sqlite3-ruby recently published an improvement to make it easier and
more flexible to load extensions:

sparklemotion/sqlite3-ruby#586

Ruby modules for SQLite extensions should implement the interface:

    interface _ExtensionSpecifier
      def to_path: () → String
    end

A complementary change in Rails takes advantage of this interface to
integrate the primary configuration file with the new sqlite3-ruby
interface for extension loading:

rails/rails#53827

The gem template provided here already has a similar method:

    def loadable_path

The change proposed here is to modify the gem template to provide an
alias to loadable_path as to_path.o

    # example
    SqliteVec.to_path # => returns same result as loadable_path

As a result of this change, Ruby gems published with this tool will
conform to the new interface supported in sqlite3-ruby and Rails.
  • Loading branch information
rossta committed Dec 12, 2024
1 parent 6ea6486 commit ad6d30a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,14 @@ module {module_name}
def self.loadable_path
File.expand_path('{entrypoint}', File.dirname(__FILE__))
end
def self.load(db)
db.load_extension(self.loadable_path)
end
class << self
alias_method :to_path, :loadable_path
end
end
"#
Expand Down

0 comments on commit ad6d30a

Please sign in to comment.