module CZTop::Config::Serialization
Methods used around serialization of {CZTop::Config} items.
Public Instance Methods
_dump(_level)
click to toggle source
Serialize (marshal) this Config
and all its children.
@note This method is automatically used by Marshal.dump. @return [String] marshalled {Config}
# File lib/cztop/config/serialization.rb, line 74 def _dump(_level) to_s end
filename()
click to toggle source
Returns the path/filename of the file this {Config} tree was loaded from. @return [String]
# File lib/cztop/config/serialization.rb, line 11 def filename ffi_delegate.filename end
reload()
click to toggle source
Reload config tree from same file that it was previously loaded from. @raise [TypeError] if this is an in-memory config @raise [SystemCallError] if this fails (no existing data will be
changed)
@return [void]
# File lib/cztop/config/serialization.rb, line 59 def reload # NOTE: can't use Zconfig.reload, as we won't get the self pointer that # gets reassigned by zconfig_reload(). We can just use Zconfig.load and # swap out the FFI delegate. filename = filename() or raise TypeError, "can't reload in-memory config" ptr = CZMQ::FFI::Zconfig.load(filename) return attach_ffi_delegate(ptr) unless ptr.null? raise_zmq_err("error while reloading from the file %p" % filename) end
save(path)
click to toggle source
Saves the Config
tree to a file. @param path [String, Pathname, to_s
] the path to the ZPL config file @return [void] @raise [SystemCallError] if this fails
# File lib/cztop/config/serialization.rb, line 48 def save(path) rc = ffi_delegate.save(path.to_s) return if rc == 0 raise_zmq_err("error while saving to the file %s" % path) end
to_s()
click to toggle source
Serialize to a string in the ZPL format. @return [String]
# File lib/cztop/config/serialization.rb, line 5 def to_s ffi_delegate.str_save.read_string end