Class: Woodhouse::NodeConfiguration

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/woodhouse/node_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ NodeConfiguration

Returns a new instance of NodeConfiguration.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
15
# File 'lib/woodhouse/node_configuration.rb', line 8

def initialize
  self.default_threads = 1
  self.dispatcher_middleware = Woodhouse::MiddlewareStack.new(self)
  self.runner_middleware = Woodhouse::MiddlewareStack.new(self)
  self.server_info = {}
  self.triggers = Woodhouse::TriggerSet.new
  yield self if block_given?
end

Instance Attribute Details

#default_threadsObject

Returns the value of attribute default_threads.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def default_threads
  @default_threads
end

#dispatcher_middlewareObject

Returns the value of attribute dispatcher_middleware.



5
6
7
# File 'lib/woodhouse/node_configuration.rb', line 5

def dispatcher_middleware
  @dispatcher_middleware
end

#dispatcher_typeObject

Returns the value of attribute dispatcher_type.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def dispatcher_type
  @dispatcher_type
end

#loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def logger
  @logger
end

#registryObject

Returns the value of attribute registry.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def registry
  @registry
end

#runner_middlewareObject

Returns the value of attribute runner_middleware.



5
6
7
# File 'lib/woodhouse/node_configuration.rb', line 5

def runner_middleware
  @runner_middleware
end

#runner_typeObject

Returns the value of attribute runner_type.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def runner_type
  @runner_type
end

#server_infoObject

Returns the value of attribute server_info.



4
5
6
# File 'lib/woodhouse/node_configuration.rb', line 4

def server_info
  @server_info
end

#triggersObject

Returns the value of attribute triggers.



6
7
8
# File 'lib/woodhouse/node_configuration.rb', line 6

def triggers
  @triggers
end

Instance Method Details

#at(event_name, &blk) ⇒ Object



17
18
19
# File 'lib/woodhouse/node_configuration.rb', line 17

def at(event_name, &blk)
  triggers.add(event_name, &blk)
end

#dispatcherObject



21
22
23
# File 'lib/woodhouse/node_configuration.rb', line 21

def dispatcher
  @dispatcher ||= dispatcher_type.new(self)
end

#extension(name, opts = {}, &blk) ⇒ Object



45
46
47
# File 'lib/woodhouse/node_configuration.rb', line 45

def extension(name, opts = {}, &blk)
  Woodhouse::Extension.install_extension(name, self, opts, &blk)
end

#load_yaml(path, keyw = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/woodhouse/node_configuration.rb', line 49

def load_yaml(path, keyw = {})
  return unless File.exist?(path)

  section     = keyw[:section]
  environment = keyw[:environment]

  config_info = YAML.load(File.read(path))
  
  if environment
    config_info = config_info[environment]
  end
  if section
    config_info = { section => config_info }
  end

  set config_info
end

#set(hash) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/woodhouse/node_configuration.rb', line 67

def set(hash)
  return unless hash

  hash.each do |key, val|
    if respond_to?("#{key}=")
      send("#{key}=", val)
    end
  end
end