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

- (NodeConfiguration) initialize {|_self| ... }

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

- (Object) default_threads

Returns the value of attribute default_threads



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

def default_threads
  @default_threads
end

- (Object) dispatcher_middleware

Returns the value of attribute dispatcher_middleware



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

def dispatcher_middleware
  @dispatcher_middleware
end

- (Object) dispatcher_type

Returns the value of attribute dispatcher_type



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

def dispatcher_type
  @dispatcher_type
end

- (Object) logger

Returns the value of attribute logger



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

def logger
  @logger
end

- (Object) registry

Returns the value of attribute registry



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

def registry
  @registry
end

- (Object) runner_middleware

Returns the value of attribute runner_middleware



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

def runner_middleware
  @runner_middleware
end

- (Object) runner_type

Returns the value of attribute runner_type



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

def runner_type
  @runner_type
end

- (Object) server_info

Returns the value of attribute server_info



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

def server_info
  @server_info
end

- (Object) triggers

Returns the value of attribute triggers



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

def triggers
  @triggers
end

Instance Method Details

- (Object) at(event_name, &blk)



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

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

- (Object) dispatcher



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

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

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



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

- (Object) load_yaml(path, keyw = {})



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

- (Object) set(hash)



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