Module: Cargobull::Env

Defined in:
lib/cargobull/env.rb

Constant Summary collapse

DEFAULTS =
{
  dispatch_url: "/api",
  file_url: "/",
  default_files: ["index.html", "index.htm"],
  default_path: nil,
  ctype: "text/plain",
  e403: "Forbidden",
  e404: "Not found",
  e405: "Method not allowed",
  e500: "Internal error",
  transform_out: nil,
  transform_in: nil
}

Class Method Summary collapse

Class Method Details

.get(*args) ⇒ Object



22
23
24
# File 'lib/cargobull/env.rb', line 22

def self.get(*args)
  update(DEFAULTS.dup, *args)
end

.update(env, *args) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/cargobull/env.rb', line 26

def self.update(env, *args)
  (args.first.is_a?(Hash) ? args.first : Hash[*args]).reduce(env) do
    |acc, (k, v)|

    acc[k.to_sym] = respond_to?(k) ? send(k, v) : v
    next acc
  end
end