Module-Generic

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    If this is not provided, it will get it with the object `error` method, or the class global variable `$ERROR`

## quiet

Set or get the object property _quiet_ to true or false. If this is true, no warning will be issued when ["error"](#error) is called.

## save

Provided with some data and a file path, or alternatively an hash reference of options with the properties _data_, _encoding_ and _file_, this will write to the given file the provided _data_ using the encoding _encoding_.

This is designed to simplify the tedious task of write to files.

If it cannot open the file in write mode, or cannot print to it, this will set an error and return undef. Otherwise this returns the size of the file in bytes.

## serialise

This method use a specified serialiser class and serialise the given data either by returning it or by saving it directly to a given file.

The serialisers currently supported are: [CBOR::Free](https://metacpan.org/pod/CBOR%3A%3AFree), [CBOR::XS](https://metacpan.org/pod/CBOR%3A%3AXS), [JSON](https://metacpan.org/pod/JSON), [Sereal](https://metacpan.org/pod/Sereal) and [Storable::Improve...

This method takes some data and an optional hash or hash reference of parameters. It can then:

- save data directly to File
- save data to a file handle (only with [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved) / [Storable](https://metacpan.org/pod/Storable))
- Return the serialised data

The supported parameters are:

- `append`

    Boolean. If true, the serialised data will be appended to the given file. This works only in conjonction with _file_

- `base64`

    Thise can be set to a true value like `1`, or to your preferred base64 encoder/decoder, or to an array reference containing 2 code references, the first one for encoding and the second one for decoding.

    If this is set simply to a true value, `serialise` will call ["\_has\_base64"](#_has_base64) to find out any installed base64 modules. Currently the ones supported are: [Crypt::Misc](https://metacpan.org/pod/Crypt%3A%3AMisc) and [MIME::Base64](ht...

    If this option is set and no appropriate module could be found, `serialise` will return an error.

- `file`

    String. A file path where to store the serialised data.

- `io`

    A file handle. This is used when the serialiser is [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved) / [Storable](https://metacpan.org/pod/Storable) to call its function ["store\_fd" in Storable::Improved](https://metacpan.org...

- `lock`

    Boolean. If true, this will lock the file before writing to it. This works only in conjonction with _file_ and the serialiser [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved)

- `serialiser` or `serializer`

    A string being the class of the serialiser to use. This can be only either [Sereal](https://metacpan.org/pod/Sereal) or [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved)

Additionally the following options are supported and passed through directly for each serialiser:

- [CBOR::Free](https://metacpan.org/pod/CBOR%3A%3AFree): `canonical`, `string_encode_mode`, `preserve_references`, `scalar_references`
- [CBOR](https://metacpan.org/pod/CBOR%3A%3AXS): `max_depth`, `max_size`, `allow_unknown`, `allow_sharing`, `allow_cycles`, `forbid_objects`, `pack_strings`, `text_keys`, `text_strings`, `validate_utf8`, `filter`
- [JSON](https://metacpan.org/pod/JSON): `allow_blessed` `allow_nonref` `allow_unknown` `allow_tags` `ascii` `boolean_values` `canonical` `convert_blessed` `filter_json_object` `filter_json_single_key_object` `indent` `latin1` `max_depth` `max_size` ...
- ["encode" in Sereal::Decoder](https://metacpan.org/pod/Sereal%3A%3ADecoder#encode) if the serialiser is [Sereal](https://metacpan.org/pod/Sereal): `aliased_dedupe_strings`, `canonical`, `canonical_refs`, `compress`, `compress_level`, `compress_thre...
- [Storable::Improved](https://metacpan.org/pod/Storable%3A%3AImproved) / [Storable](https://metacpan.org/pod/Storable): no option available

If an error occurs, this sets an [error](https://metacpan.org/pod/Module%3A%3AGeneric#error) and return `undef`

## serialize

Alias for ["serialise"](#serialise)

## set

**set**() sets object inner data type and takes arguments in a hash like fashion:

    $obj->set( 'verbose' => 1, 'debug' => 0 );

## subclasses

Provided with a _CLASS_ value, this method try to guess all the existing sub classes of the provided _CLASS_.

If _CLASS_ is not provided, the class into which was blessed the calling object will
be used instead.

It returns an array of subclasses in list context and a reference to an array of those
subclasses in scalar context.

If an error occured, undef is returned and an error is set accordingly. The latter can
be retrieved using the **error** method.

## true

Returns a `true` variable from [Module::Generic::Boolean](https://metacpan.org/pod/Module%3A%3AGeneric%3A%3ABoolean)

## false

Returns a `false` variable from [Module::Generic::Boolean](https://metacpan.org/pod/Module%3A%3AGeneric%3A%3ABoolean)

## verbose

Set or get the verbosity level with an integer.

## will

This will try to find out if an object supports a given method call and returns the code reference to it or undef if none is found.

## AUTOLOAD

The special **AUTOLOAD**() routine is called by perl when no matching routine was found
in the module.

**AUTOLOAD**() will then try hard to process the request.
For example, let's assue we have a routine **foo**.

It will first, check if an equivalent entry of the routine name that was called exist in
the hash reference of the object. If there is and that more than one argument were
passed to this non existing routine, those arguments will be stored as a reference to an
array as a value of the key in the object. Otherwise the single argument will simply be stored
as the value of the key of the object.

Then, if called in list context, it will return a array if the value of the key entry was an array
reference, or a hash list if the value of the key entry was a hash reference, or finally the value



( run in 2.319 seconds using v1.01-cache-2.11-cpan-df04353d9ac )