Class: Phut::Syntax::NetnsDirective

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

Overview

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

Instance Method Summary collapse

Methods inherited from Directive

#[], attribute

Constructor Details

#initialize(alias_name, &block) ⇒ NetnsDirective

Returns a new instance of NetnsDirective.



9
10
11
12
# File 'lib/phut/syntax/netns_directive.rb', line 9

def initialize(alias_name, &block)
  @attributes = { name: alias_name }
  instance_eval(&block)
end

Instance Method Details

#ip(value) ⇒ Object



14
15
16
17
# File 'lib/phut/syntax/netns_directive.rb', line 14

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

#route(options) ⇒ Object



19
20
21
22
# File 'lib/phut/syntax/netns_directive.rb', line 19

def route(options)
  @attributes[:net] = options.fetch(:net)
  @attributes[:gateway] = options.fetch(:gateway)
end