Sha256: c6fcb0526b56dc2217f685e04144e932479b78df458d5f6cb4af78f2e4eb1025

Contents?: true

Size: 675 Bytes

Versions: 6

Compression:

Stored size: 675 Bytes

Contents

require "dry/core/inflector"

<%= config[:camel_cased_app_name] %>::Container.namespace :repos do |container|
  container.finalize :repos do
    init do
      Dir[container.root.join("app/repositories/*.rb")].each do |repo|
        require repo
      end
    end

    start do
      db = container.resolve("persistence.rom")

      Dir[container.root.join("app/repositories/*.rb")].each do |repo|
        repo_name = File.basename(repo, ".rb")
        klass_name = Dry::Core::Inflector.camelize(repo_name)
        klass = Dry::Core::Inflector.constantize("Repositories::#{klass_name}")

        container.register(repo_name.to_sym, klass.new(db))
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kanji-web-0.3.1 lib/kanji/templates/system/boot/repos.rb.tt
kanji-web-0.3.0 lib/kanji/templates/system/boot/repos.rb.tt
kanji-web-0.2.2 lib/kanji/templates/system/boot/repos.rb.tt
kanji-web-0.2.1 lib/kanji/templates/system/boot/repos.rb.tt
kanji-web-0.2.0 lib/kanji/templates/system/boot/repos.rb.tt
kanji-web-0.1.0 lib/kanji/templates/system/boot/repos.rb.tt