Class: Configuration::Scope

Inherits:
Object
  • Object
show all
Includes:
ClassLogging
Defined in:
lib/httpimagestore/configuration.rb

Direct Known Subclasses

Global, Handler, SourceFailover

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Scope

Returns a new instance of Scope.



104
105
106
# File 'lib/httpimagestore/configuration.rb', line 104

def initialize(configuration)
  @configuration = configuration
end

Class Method Details

.node_parsersObject



95
96
97
# File 'lib/httpimagestore/configuration.rb', line 95

def self.node_parsers
  @node_parsers ||= []
end

.register_node_parser(parser) ⇒ Object



99
100
101
102
# File 'lib/httpimagestore/configuration.rb', line 99

def self.register_node_parser(parser)
  parser.logger = logger_for(parser) if parser.respond_to? :logger=
  node_parsers << parser
end

Instance Method Details

#parse(node) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/httpimagestore/configuration.rb', line 108

def parse(node)
  self.class.node_parsers.each do |parser|
    parser.pre(@configuration) if parser.respond_to? :pre
  end

  node.children.each do |node|
    parser = self.class.node_parsers.find do |parser|
      parser.match node
    end
    if parser
      parser.parse(@configuration, node)
    else
      log.warn "unexpected statement: #{node.name}"
    end
  end

  self.class.node_parsers.each do |parser|
    parser.post(@configuration) if parser.respond_to? :post
  end
  @configuration
end