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:



49
50
51
# File 'lib/cztop/config/serialization.rb', line 49

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:



26
27
28
# File 'lib/cztop/config/serialization.rb', line 26

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



35
36
37
38
39
40
41
42
# File 'lib/cztop/config/serialization.rb', line 35

def load(path)
  ptr = CZMQ::FFI::Zconfig.load(path.to_s)
  return from_ffi_delegate(ptr) unless ptr.null?

  CZTop::HasFFIDelegate.raise_zmq_err(
    format('error while reading the file %p', path.to_s)
  )
end