class Nginxtra::Config::Extension
Extension
point for other gems or libraries that want to define inline partials. Please see the partial method for usage.
Public Class Methods
Clear all partials so far defined. This is mainly for test, but could be called if resetting is so desired.
# File lib/nginxtra/config.rb, line 357 def clear_partials! @extensions = {} end
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.
# 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
Determine if there has been a partial defined for the given nginx config file, with the given partial name.
# File lib/nginxtra/config.rb, line 319 def partial?(file, name) file = file.to_sym name = name.to_sym @extensions && @extensions[file] && @extensions[file][name] end