Class: Phut::Syntax::VhostDirective

Inherits:
Object
  • Object
show all
Defined in:
lib/phut/syntax.rb

Overview

The ‘vhost(name) { …attributes… }’ directive.

Defined Under Namespace

Classes: UnusedIpAddress

Constant Summary collapse

UnusedIpAddressSingleton =
UnusedIpAddress.new

Instance Method Summary collapse

Constructor Details

#initialize(alias_name, &block) ⇒ VhostDirective

Returns a new instance of VhostDirective.



46
47
48
49
50
51
52
53
# File 'lib/phut/syntax.rb', line 46

def initialize(alias_name, &block)
  @attributes = { name: alias_name }
  if block
    instance_eval(&block) if block
  else
    @attributes[:ip] = UnusedIpAddressSingleton.generate
  end
end

Instance Method Details

#[](key) ⇒ Object



64
65
66
# File 'lib/phut/syntax.rb', line 64

def [](key)
  @attributes[key]
end

#ip(value) ⇒ Object



55
56
57
58
# File 'lib/phut/syntax.rb', line 55

def ip(value)
  @attributes[:ip] = value
  @attributes[:name] ||= value
end

#promisc(on_off) ⇒ Object



60
61
62
# File 'lib/phut/syntax.rb', line 60

def promisc(on_off)
  @attributes[:promisc] = on_off
end