Module: CZTop::Config::Serialization::ClassMethods

Included in:
CZTop::Config
Defined in:
lib/cztop/config/serialization.rb

Overview

Some class methods for CZTop::Config related to serialization.

Instance Method Summary collapse

Instance Method Details

#_load(string) ⇒ Config

Note:

This method is automatically used by Marshal.load.

Loads a CZTop::Config tree from a marshalled string.

Parameters:

Returns:



39
40
41
# File 'lib/cztop/config/serialization.rb', line 39

def _load(string)
  from_string(string)
end

#from_string(string) ⇒ Config

Loads a CZTop::Config tree from a string.

Parameters:

  • string (String)

    the tree

Returns:



20
21
22
# File 'lib/cztop/config/serialization.rb', line 20

def from_string(string)
  from_ffi_delegate CZMQ::FFI::Zconfig.str_load(string)
end

#load(path) ⇒ Config

Loads a CZTop::Config tree from a file.

Parameters:

  • path (String, Pathname, #to_s)

    the path to the ZPL config file

Returns:

Raises:

  • (SystemCallError)

    if this fails



28
29
30
31
32
33
# File 'lib/cztop/config/serialization.rb', line 28

def load(path)
  ptr = CZMQ::FFI::Zconfig.load(path.to_s)
  return from_ffi_delegate(ptr) unless ptr.null?
  CZTop::HasFFIDelegate.raise_zmq_err(
    "error while reading the file %p" % path.to_s)
end