Module: Woodhouse::GlobalMethods

Included in:
Woodhouse
Defined in:
lib/woodhouse.rb

Overview

TODO: hate keeping global state in this class. I need to push some of this down into NodeConfiguration or something like it.

Instance Method Summary collapse

Instance Method Details

#configure {|@global_configuration| ... } ⇒ Object

Yields:

  • (@global_configuration)


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

def configure
  @global_configuration ||= Woodhouse::NodeConfiguration.default
  yield @global_configuration
end

#dispatch(*a) ⇒ Object



65
66
67
# File 'lib/woodhouse.rb', line 65

def dispatch(*a)
  dispatcher.dispatch(*a)
end

#dispatcherObject



61
62
63
# File 'lib/woodhouse.rb', line 61

def dispatcher
  global_configuration.dispatcher
end

#global_configurationObject



38
39
40
# File 'lib/woodhouse.rb', line 38

def global_configuration
  @global_configuration ||= Woodhouse::NodeConfiguration.default
end

#global_layoutObject



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

def global_layout
  @global_layout ||= Woodhouse::Layout.default
end

#layout {|Woodhouse::LayoutBuilder.new(Woodhouse.global_configuration, @global_layout)| ... } ⇒ Object

Yields:



51
52
53
54
# File 'lib/woodhouse.rb', line 51

def layout
  @global_layout ||= Woodhouse::Layout.new
  yield Woodhouse::LayoutBuilder.new(Woodhouse.global_configuration, @global_layout)
end

#loggerObject



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

def logger
  global_configuration.logger
end

#threading_safe?Boolean

Returns true on JRuby, Rubinius, or MRI 1.9. false otherwise.

Returns:

  • (Boolean)


57
58
59
# File 'lib/woodhouse.rb', line 57

def threading_safe?
  RUBY_VERSION.to_f >= 1.9 or %w[jruby rbx].include?(RUBY_ENGINE)
end

#update_job(*a) ⇒ Object



69
70
71
# File 'lib/woodhouse.rb', line 69

def update_job(*a)
  dispatcher.update_job(*a)
end

#watchdogObject



73
74
75
# File 'lib/woodhouse.rb', line 73

def watchdog
  Woodhouse::Watchdog.instance
end