Sha256: 712bbdf20848985c105db95d9bfa3e016722cba033b4bd722a56b08d82eaea15

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

require "roda"
require "roda/plugins/flow"
require "dry-configurable"

module Dry
  module Web
    module Roda
      class Application < ::Roda
        extend Dry::Configurable

        setting :container, reader: true
        setting :routes

        plugin :multi_route
        plugin :flow
        plugin :error_handler

        def self.configure(&block)
          super.tap do
            use(container[:rack_monitor]) if container.config.listeners
          end
        end

        def self.resolve(name)
          container[name]
        end

        def self.[](name)
          container[name]
        end

        def self.load_routes!
          Dir[root.join("#{config.routes}/**/*.rb")].each { |f| require f }
        end

        def self.root
          container.config.root
        end

        def notifications
          self.class[:notifications]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-web-roda-0.8.0 lib/dry/web/roda/application.rb
dry-web-roda-0.7.5 lib/dry/web/roda/application.rb