Class: James::Bond

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/james/bond.rb,
lib/james/bond/settings.rb

Direct Known Subclasses

Main

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.root_path(*args) ⇒ Object

Helper method for file references.

Examples:

Referencing a file in config called settings.yml:

root_path("config", "settings.yml")

Parameters:

  • args (Array)

    Path components relative to ROOT_DIR.



13
14
15
# File 'lib/james/bond.rb', line 13

def self.root_path(*args)
  File.join(James.root, *args)
end

.settings(key) ⇒ Object

TODO Add documentation.



6
7
8
9
10
11
12
13
14
15
# File 'lib/james/bond/settings.rb', line 6

def self.settings(key)
  @settings ||= YAML.load_file(root_path("config", "settings.yml"))[RACK_ENV.to_sym]

  unless @settings.include?(key)
    message = "No setting defined for #{key.inspect}."
    defined?(logger) ? logger.warn(message) : $stderr.puts(message)
  end

  @settings[key]
end

Instance Method Details

#root_path(*args) ⇒ Object

See Also:



18
19
20
# File 'lib/james/bond.rb', line 18

def root_path(*args)
  self.class.root_path(*args)
end

#settings(key) ⇒ Object



17
18
19
# File 'lib/james/bond/settings.rb', line 17

def settings(key)
  self.class.settings(key)
end