module Roda::RodaPlugins::Environments

  1. lib/roda/plugins/environments.rb

The environments plugin adds a environment class accessor to get the environment for the application, 3 predicate class methods to check for the current environment (development?, test? and production?), and a class configure method that takes environment(s) and yields to the block if the given environment(s) match the current environment.

The default environment for the application is based on ENV['RACK_ENV'].


class Roda
  plugin :environments

  environment  # => :development
  development? # => true
  test?        # => false
  production?  # => false

  # Set the environment for the application
  self.environment = :test 
  test?        # => true

  configure do
    # called, as no environments given

  configure :development, :production do
    # not called, as no environments match

  configure :test do
    # called, as environment given matches current environment


Public Class

  1. configure

Public Class methods

configure(app, env=ENV["RACK_ENV"])

Set the environment to use for the app. Default to ENV if no environment is given. If ENV is not set and no environment is given, assume the development environment.

[show source]
   # File lib/roda/plugins/environments.rb
46 def self.configure(app, env=ENV["RACK_ENV"])
47   app.environment = (env || 'development').to_sym
48 end