Is it possible to use external Adapters in Hanami::Model?


#1

Hi!
I apologize if this question has been asked or is obvious, I’m a little new to the Hanami Model library. I was toying around with adding a new adapter for a different database. This was just for me to familiarize myself more with Hanami.

So I have an implementation of Abstract that defines a few of the methods. This adapter (FiebaseAdapter) seems functional, but I can't get my container app to load it.

Following along in the debugger it seems to boil down to this line:

# hanami/model/config/adapter - 'load_adapter' method on lines 94 - 100:

    def load_adapter
      begin
        require "hanami/model/adapters/#{type}_adapter"
      rescue LoadError => e
        raise LoadError.new("Cannot find Hanami::Model adapter '#{type}' (#{e.message})")
      end
    end

I also saw this in the comments at the top:

"      
# By convention, Hanami inflects type to find the adapter class
# For example, if type is :sql, derived class will be `Hanami::Model::Adapters::SqlAdapter`
"

Does this mean any adapter we want to use has to be loaded from within hanami/model/adapters?

If I wanted to experiment with a new adapter for a different data back-end, how can I get Hanami to be able to load it?

Again, hopefully I haven’t missed anything obvious. I thank you for any help and apologize if this is a silly question.

Thanks!