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.



35
36
37
38
39
40
# File 'lib/runtime/application.rb', line 35

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.



29
30
31
# File 'lib/runtime/application.rb', line 29

def instance
  @instance
end

Instance Attribute Details

#optionsObject (readonly)

Accessor for options passed to the application.



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

def options
  @options
end

Instance Method Details

#cacheObject

Returns the cache set for the current configuration



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

def cache ; config.cache ; end

#configObject

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



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

def config
  Waves.application.configurations[ mode ]
end

#debug?Boolean

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

Returns:

  • (Boolean)


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

def debug? ; config.debug ; end

#mappingObject

Access the mappings for the application.



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

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

#modeObject

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



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

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

#reloadObject

Reload the modules specified in the current configuration.



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

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

#synchronize(&block) ⇒ Object



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

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