Class: Waves::Application

Inherits:
Object show all
Defined in:
lib/runtime/application.rb

Overview

An application in Waves is anything that provides access to the Waves runtime and the registered Waves applications. This includes both Waves::Server and Waves::Console. Waves::Application is not the actual application module(s) registered as Waves applications. To access the main Waves application, you can use Waves.application.

Direct Known Subclasses

Console, Server

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Application

Create a new Waves application instance.



37
38
39
40
41
42
# File 'lib/runtime/application.rb', line 37

def initialize( options={} )
  @options = options
  Dir.chdir options[:directory] if options[:directory]
  Application.instance = self
  Kernel.load( :lib / 'application.rb' ) if Waves.application.nil?
end

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



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

def instance
  @instance
end

Instance Attribute Details

#optionsObject (readonly)

Accessor for options passed to the application. Valid options include



34
35
36
# File 'lib/runtime/application.rb', line 34

def options
  @options
end

Instance Method Details

#cacheObject

Returns the cache set for the current configuration



62
# File 'lib/runtime/application.rb', line 62

def cache ; config.cache ; end

#configObject

Access the current configuration. Example: Waves::Server.config



53
# File 'lib/runtime/application.rb', line 53

def config ; Waves.application.configurations[ mode ] ; end

#debug?Boolean

Debug is true if debug is set to true in the current configuration.

Returns:

  • (Boolean)


50
# File 'lib/runtime/application.rb', line 50

def debug? ; config.debug ; end

#mappingObject

Access the mappings for the application.



56
# File 'lib/runtime/application.rb', line 56

def mapping ; Waves.application.configurations[ :mapping ] ; end

#modeObject

The ‘mode’ of the application determines which configuration it will run under.



47
# File 'lib/runtime/application.rb', line 47

def mode ; @mode ||= @options[:mode]||:development ; end

#reloadObject

Reload the modules specified in the current configuration.



59
# File 'lib/runtime/application.rb', line 59

def reload ; config.reloadable.each { |mod| mod.reload } ; end

#synchronize(&block) ⇒ Object



44
# File 'lib/runtime/application.rb', line 44

def synchronize( &block ) ; ( @mutex ||= Mutex.new ).synchronize( &block ) ; end