Class: Phut::Syntax::VhostDirective
- Defined in:
- lib/phut/syntax/vhost_directive.rb
Overview
The ‘vhost(name) { …attributes… }’ directive.
Defined Under Namespace
Classes: UnusedIpAddress
Constant Summary collapse
- UnusedIpAddressSingleton =
UnusedIpAddress.new
Instance Method Summary collapse
-
#initialize(alias_name, &block) ⇒ VhostDirective
constructor
A new instance of VhostDirective.
- #ip(value) ⇒ Object
Methods inherited from Directive
#[], attribute, #method_missing
Constructor Details
#initialize(alias_name, &block) ⇒ VhostDirective
Returns a new instance of VhostDirective.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/phut/syntax/vhost_directive.rb', line 26 def initialize(alias_name, &block) @attributes = { name: alias_name, mac: Pio::Mac.new(rand(0xffffffffffff + 1)), promisc: false } if block instance_eval(&block) else @attributes[:ip] = UnusedIpAddressSingleton.generate end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Phut::Syntax::Directive
Instance Method Details
#ip(value) ⇒ Object
38 39 40 41 |
# File 'lib/phut/syntax/vhost_directive.rb', line 38 def ip(value) @attributes[:ip] = value @attributes[:name] ||= value end |