Module: Rage

Defined in:
lib/rage-rb.rb,
lib/rage/cli.rb,
lib/rage/version.rb

Defined Under Namespace

Modules: Cable, Deferred, Errors, Events, Ext, OpenAPI, Router Classes: Application, CLI, CLICodeGenerator, CLINewAppGenerator, CodeLoader, Configuration, Cookies, Cors, Env, FiberScheduler, FiberWrapper, JSONFormatter, LogProcessor, Logger, OriginValidator, ParamsParser, Reloader, Request, RequestId, Response, Session, SidekiqSession, Tasks, TextFormatter, UploadedFile

Constant Summary collapse

VERSION =
"1.19.0"

Class Method Summary collapse

Class Method Details

.applicationObject

Builds the Rage application with the configured middlewares.



10
11
12
# File 'lib/rage-rb.rb', line 10

def self.application
  with_middlewares(Application.new(__router), config.middleware.middlewares)
end

.cableRage::Cable

Shorthand to access Rage::Cable.

Returns:



21
22
23
# File 'lib/rage-rb.rb', line 21

def self.cable
  Rage::Cable
end

.configRage::Configuration Also known as: configuration

Access the Rage configuration.

Returns:



65
66
67
# File 'lib/rage-rb.rb', line 65

def self.config
  @config ||= Rage::Configuration.new
end

.configureObject

Configure Rage using a block.

Examples:

Rage.configure do |config|
  config.log_level = :debug
end


74
75
76
77
# File 'lib/rage-rb.rb', line 74

def self.configure(&)
  config.instance_eval(&)
  config.__finalize
end

.deferredRage::Deferred

Shorthand to access Rage::Deferred.

Returns:



33
34
35
# File 'lib/rage-rb.rb', line 33

def self.deferred
  Rage::Deferred
end

.envRage::Env

Access the current Rage environment.

Examples:

if Rage.env.development?
  puts "Running in development mode"
end

Returns:

  • (Rage::Env)

    the Rage environment instance



85
86
87
# File 'lib/rage-rb.rb', line 85

def self.env
  @__env ||= Rage::Env.new(ENV["RAGE_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end

.eventsRage::Events

Shorthand to access Rage::Events.

Returns:



39
40
41
# File 'lib/rage-rb.rb', line 39

def self.events
  Rage::Events
end

.groupsObject

Access the current Gem groups based on the Rage environment.



90
91
92
# File 'lib/rage-rb.rb', line 90

def self.groups
  [:default, Rage.env.to_sym]
end

.load_middlewares(_) ⇒ Object

Deprecated.

This method is deprecated and has been merged into Rage.application.

Load middlewares into the Rage application.



108
109
110
# File 'lib/rage-rb.rb', line 108

def self.load_middlewares(_)
  puts "`Rage.load_middlewares` is deprecated and has been merged into `Rage.application`. Please remove this call."
end

.load_tasksObject

Load Rake tasks for the Rage application.



142
143
144
# File 'lib/rage-rb.rb', line 142

def self.load_tasks
  Rage::Tasks.init
end

.loggerRage::Logger

Access the Rage logger.

Returns:



102
103
104
# File 'lib/rage-rb.rb', line 102

def self.logger
  @logger ||= config.logger
end

.multi_applicationObject

Builds the Rage application which delegates Rails requests to Rails.application.



15
16
17
# File 'lib/rage-rb.rb', line 15

def self.multi_application
  Rage::Router::Util::Cascade.new(application, Rails.application)
end

.openapiRage::OpenAPI

Shorthand to access Rage::OpenAPI.

Returns:



27
28
29
# File 'lib/rage-rb.rb', line 27

def self.openapi
  Rage::OpenAPI
end

.rootPathname

Access the root path of the Rage application.

Returns:

  • (Pathname)

    the root path



96
97
98
# File 'lib/rage-rb.rb', line 96

def self.root
  @root ||= Pathname.new(".").expand_path
end

.routesRage::Router::DSL::Handler

Configure routes for the Rage application.

Examples:

Rage.routes.draw do
  root to: "users#index"
end

Returns:



49
50
51
# File 'lib/rage-rb.rb', line 49

def self.routes
  Rage::Router::DSL.new(__router)
end