Class: Waves::Runtime

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

Overview

A Waves::Runtime takes an inert application module and gives it concrete, pokeable form. Waves::Server and Waves::Console are types of runtime.

Direct Known Subclasses

Console, Worker

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runtime

Create a new Waves application instance.



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

def initialize( options={} )
  @options = options
  Dir.chdir options[:directory] if options[:directory]
  Runtime.instance = self
end

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



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

def instance
  @instance
end

Instance Attribute Details

#optionsObject (readonly)

Accessor for options passed to the runtime.



37
38
39
# File 'lib/runtime/runtime.rb', line 37

def options
  @options
end

Instance Method Details

#configObject

Returns the current configuration.



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

def config ; Waves.main::Configurations[ mode ] ; end

#debug?Boolean

Returns true if debug was set to true in the current configuration.

Returns:

  • (Boolean)


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

def debug? ; options[:debugger] or config.debug ; end

#logObject

Start and / or access the Waves::Logger instance.



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

def log ; @log ||= Waves::Logger.start ; end

#modeObject

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



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

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

#reloadObject

Reload the modules specified in the current configuration.



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

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

#synchronize(&block) ⇒ Object

Provides access to the server mutex for thread-safe operation.



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

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

#synchronize?Boolean

Returns:

  • (Boolean)


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

def synchronize? ; !options[ :turbo ] ; end