Class: PuppetHerald::App::Configuration

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/puppet-herald/app/configuration.rb

Overview

A configuration for application

Class Method Summary collapse

Class Method Details

.api?(req) ⇒ Boolean

Is request part of the API

Parameters:

  • req (Sinatra::Request)

    a request to check

Returns:

  • (Boolean)

    true, if given request point to part of the API



33
34
35
# File 'lib/puppet-herald/app/configuration.rb', line 33

def api?(req)
  (req.path.start_with?('/api') || req.path.start_with?('/version.json'))
end

.dbmigrate!nil

Migrates a database to state desired for the application

Returns:

  • (nil)


22
23
24
25
26
27
28
# File 'lib/puppet-herald/app/configuration.rb', line 22

def dbmigrate!
  ActiveRecord::Base.establish_connection(PuppetHerald.database.spec)
  setup_database_logger
  ActiveRecord::Migrator.up 'db/migrate'
  ActiveRecord::Base.clear_active_connections!
  nil
end