module ROM::Roda::Plugin

Attributes

environments[R]

Public Class Methods

configure(app, config) click to toggle source
# File lib/rom/roda/plugin.rb, line 7
def configure(app, config)
  load_paths = [*(config.delete(:load_path) || config.delete(:load_paths))].map do |path|
    File.expand_path(
      path,
      app.opts[:root]
    )
  end if config[:load_path] || config[:load_paths]

  @environments = config.each_with_object({}) do |(env_name, env_config), container|
    container[env_name] = ROM::Environment.new.tap do |env|
      env.setup(*[env_config.fetch(:setup)].flatten)

      env_config.fetch(:plugins, {}).each do |*args|
        env.use(*args.flatten)
      end
    end
  end

  load_paths.map { |path| load_files(path) } if load_paths
end
load_files(path) click to toggle source
# File lib/rom/roda/plugin.rb, line 28
def load_files(path)
  Dir["#{path}/**/*.rb"].each do |class_file|
    require class_file
  end
end