Module: Briefly::Rails

Defined in:
lib/briefly/rails.rb,
lib/briefly/rails/db.rb,
lib/briefly/rails/reload.rb

Overview

Shortcut pack for Rails applications.

App = Briefly.define { use Briefly::Rails }
App.c            # => Rails.configuration
App.render(...)  # => ApplicationController.renderer.render(...)
App.db.txn { }   # => ApplicationRecord.transaction { }

An umbrella over Config, Env, View and Reload, plus DB under the db namespace. Each is a pack in its own right, so a facade can take only the parts it wants:

Admin = Briefly.define do
use "rails/env"
namespace(:primary) { use "rails/db" }
end

Nothing here memoizes. Every shortcut is a live lookup: the framework already caches the expensive ones (+helpers+, routes, renderer) on objects it refreshes on reload, so caching them again would only go stale. Reload is still wired in, because the application's own memoized shortcuts need clearing; the mini-packs, having nothing to clear, leave it alone.

Inside this file the framework is always ::Rails — bare Rails would resolve to this module.

Defined Under Namespace

Modules: Config, DB, Env, Reload, View

Class Method Summary collapse

Class Method Details

.install(builder) ⇒ Briefly::Builder

Parameters:

Returns:



34
35
36
37
38
39
40
41
# File 'lib/briefly/rails.rb', line 34

def install(builder)
  builder.use(Reload)
  builder.use(Config)
  builder.use(Env)
  builder.use(View)
  builder.namespace(:db) { use DB }
  builder
end