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.



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

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.



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

def instance
  @instance
end

Instance Attribute Details

#optionsObject (readonly)

Accessor for options passed to the runtime.



39
40
41
# File 'lib/runtime/runtime.rb', line 39

def options
  @options
end

Instance Method Details

#configObject

Returns the current configuration.



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

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

#debug?Boolean

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

Returns:

  • (Boolean)


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

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

#logObject

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



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

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

#modeObject

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



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

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

#reloadObject

Reload the modules specified in the current configuration.



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

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

#synchronize(&block) ⇒ Object

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



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

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

#synchronize?Boolean

Returns:

  • (Boolean)


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

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