Module: App

Defined in:
lib/app.rb,
lib/app.rb

Overview

App is your app.

What would your app be without it? Still an app, but without App.

Constant Summary collapse

VERSION =
"0.2.6"
HASH_KLASS =
Object.const_defined?("HashWithIndifferentAccess") ? HashWithIndifferentAccess : Hash
@@config =

Initialize.

nil

Class Method Summary collapse

Class Method Details

.config(*args) ⇒ Object Also known as: []

Returns the application configuration hash, as defined in “config/app.yml”.

Follows args through the hash tree. E.g.:

App.config("apis", "flickr") # => config_hash["apis"]["flickr"]

App.config is aliased to App.[], so shorten things up:

App["apis", "flickr"]

Or rely on method_missing to make it even shorter (and sweeter):

App.apis("flickr")


24
25
26
27
28
# File 'lib/app.rb', line 24

def config(*args)
  read_config
  @@config if args.empty?
  args.inject(@@config) { |config, arg| config && config[arg] }
end

.inspectObject



31
32
33
# File 'lib/app.rb', line 31

def inspect
  "#<#{name}: #{config.inspect}>"
end

.to_sObject

Returns the name of the web application.



61
62
63
# File 'lib/app.rb', line 61

def to_s
  File.basename Rails.root
end