Class: Puppet::Network::FormatHandler::FormatProtector

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/puppet/network/format_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format) ⇒ FormatProtector

Returns a new instance of FormatProtector.



20
21
22
# File 'lib/vendor/puppet/network/format_handler.rb', line 20

def initialize(format)
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



9
10
11
# File 'lib/vendor/puppet/network/format_handler.rb', line 9

def format
  @format
end

Instance Method Details

#protect(method, args) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vendor/puppet/network/format_handler.rb', line 11

def protect(method, args)
    Puppet::Network::FormatHandler.format(format).send(method, *args)
rescue => details
    direction = method.to_s.include?("intern") ? "from" : "to"
    error = FormatError.new("Could not #{method} #{direction} #{format}: #{details}")
    error.set_backtrace(details.backtrace)
    raise error
end