Method: Nginxtra::Config::Extension.partial
- Defined in:
- lib/nginxtra/config.rb
.partial(file, name, &block) ⇒ Object
Define or retrieve the partial for the given nginx config file and partial name. If a block is provided, it is set as the partial, otherwise the partial currently defined for it will be retrieved. The block is expected to take 2 arguments… the arguments hash, and then the block passed in to this definition. Either may be ignored if so desired.
Example usage:
Nginxtra::Config::Extension.partial "nginx.conf", "my_app" do |args, block|
my_app(args[:port] || 80)
some_other_setting "on"
block.call
end
The partial will only be valid for the given config file. It is completely nestable, and other partials may be invoked as well.
342 343 344 345 346 347 348 349 350 351 352 353 |
# File 'lib/nginxtra/config.rb', line 342 def partial(file, name, &block) file = file.to_sym name = name.to_sym @extensions ||= {} @extensions[file] ||= {} if block @extensions[file][name] = block else @extensions[file][name] end end |