Class: Woodhouse::NodeConfiguration
- Inherits:
-
Object
- Object
- Woodhouse::NodeConfiguration
- Includes:
- Util
- Defined in:
- lib/woodhouse/node_configuration.rb
Instance Attribute Summary collapse
-
#default_threads ⇒ Object
Returns the value of attribute default_threads.
-
#dispatcher_middleware ⇒ Object
Returns the value of attribute dispatcher_middleware.
-
#dispatcher_type ⇒ Object
Returns the value of attribute dispatcher_type.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#registry ⇒ Object
Returns the value of attribute registry.
-
#runner_middleware ⇒ Object
Returns the value of attribute runner_middleware.
-
#runner_type ⇒ Object
Returns the value of attribute runner_type.
-
#server_info ⇒ Object
Returns the value of attribute server_info.
-
#triggers ⇒ Object
Returns the value of attribute triggers.
Instance Method Summary collapse
- #at(event_name, &blk) ⇒ Object
- #dispatcher ⇒ Object
- #extension(name, opts = {}, &blk) ⇒ Object
-
#initialize {|_self| ... } ⇒ NodeConfiguration
constructor
A new instance of NodeConfiguration.
- #load_yaml(path, keyw = {}) ⇒ Object
- #set(hash) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ NodeConfiguration
Returns a new instance of NodeConfiguration.
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_threads ⇒ Object
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_middleware ⇒ Object
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_type ⇒ Object
Returns the value of attribute dispatcher_type.
4 5 6 |
# File 'lib/woodhouse/node_configuration.rb', line 4 def dispatcher_type @dispatcher_type end |
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/woodhouse/node_configuration.rb', line 4 def logger @logger end |
#registry ⇒ Object
Returns the value of attribute registry.
4 5 6 |
# File 'lib/woodhouse/node_configuration.rb', line 4 def registry @registry end |
#runner_middleware ⇒ Object
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_type ⇒ Object
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_info ⇒ Object
Returns the value of attribute server_info.
4 5 6 |
# File 'lib/woodhouse/node_configuration.rb', line 4 def server_info @server_info end |
#triggers ⇒ Object
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 |
#dispatcher ⇒ Object
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 |