Class: VhostGenerator::NginxGenerator
- Inherits:
-
Object
- Object
- VhostGenerator::NginxGenerator
- Defined in:
- lib/vhost_generator/nginx_generator.rb
Overview
Nginx VhostGenerator
Instance Attribute Summary collapse
-
#cfg ⇒ Object
readonly
Returns the value of attribute cfg.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(cfg, options = {}) ⇒ NginxGenerator
constructor
A new instance of NginxGenerator.
- #render ⇒ Object
Constructor Details
#initialize(cfg, options = {}) ⇒ NginxGenerator
Returns a new instance of NginxGenerator.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vhost_generator/nginx_generator.rb', line 10 def initialize(cfg, ={}) @cfg = cfg @options = OpenStruct.new(.merge()) @options.upstream ||= cfg.application @options.has_upstream = cfg.instance_ports.length > 1 @options.proxy_pass = if @options.has_upstream @options.upstream elsif cfg.instance_ports.length > 0 "localhost:#{cfg.instance_ports.first}" else raise ArgumentError, "Please specify at least 1 instance-port." end @options.freeze end |
Instance Attribute Details
#cfg ⇒ Object (readonly)
Returns the value of attribute cfg.
9 10 11 |
# File 'lib/vhost_generator/nginx_generator.rb', line 9 def cfg @cfg end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/vhost_generator/nginx_generator.rb', line 9 def @options end |
Instance Method Details
#render ⇒ Object
26 27 28 |
# File 'lib/vhost_generator/nginx_generator.rb', line 26 def render template.result(binding) end |