Module: Yodatra::Boot

Defined in:
lib/yodatra/boot.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/yodatra/boot.rb', line 19

def self.registered app
  raise "Check it out O'man! You're trying to boot the app [#{app}] which is already booted!" if app.booted
  if app.booting
    # ActiveRecord
    app.register Sinatra::ActiveRecordExtension

    app_file = "#{app.config_directory}/application.rb"
    require File.expand_path(app_file) if File.exist? app_file

    env_file = "#{app.envs_directory}/#{app.environment}.rb"
    require File.expand_path(env_file) if File.exist? env_file

    %w(models_directory controllers_directory).each do |to_load|
      Dir["#{app.send(to_load)}/**/*.rb"].sort.each do |file_path|
        require File.expand_path(file_path)
      end
    end

    app.set :booting, false
    app.set :booted, true
  end
end

Instance Method Details

#booting=(done) ⇒ Object



14
15
16
17
# File 'lib/yodatra/boot.rb', line 14

def booting= done
  super
  register Yodatra::Boot
end