| 1 | # Copyright Infomation | ||
| 2 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | # Author : Dr. Ahmed Amin Elsheshtawy, Ph.D. | ||
| 4 | # Website: https://github.com/mewsoft/Nile, http://www.mewsoft.com | ||
| 5 | # Email : mewsoft@cpan.org, support@mewsoft.com | ||
| 6 | # Copyrights (c) 2014-2015 Mewsoft Corp. All rights reserved. | ||
| 7 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 8 | package Nile::Serialization; | ||
| 9 | |||
| 10 | our $VERSION = '0.55'; | ||
| 11 | our $AUTHORITY = 'cpan:MEWSOFT'; | ||
| 12 | |||
| 13 | =pod | ||
| 14 | |||
| 15 | =encoding utf8 | ||
| 16 | |||
| 17 | =head1 NAME | ||
| 18 | |||
| 19 | Nile::Serialization - Base class for L<Nile::Serializer> and L<Nile::Deserializer> | ||
| 20 | |||
| 21 | =head1 SYNOPSIS | ||
| 22 | |||
| 23 | $app->freeze; | ||
| 24 | $app->thaw; | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | Nile::Serialization - Base class for L<Nile::Serializer> and L<Nile::Deserializer> | ||
| 29 | |||
| 30 | This is a base class for L<Nile::Serializer> and L<Nile::Deserializer> modules. It also provides direct access to the serialization classes. | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | #use Nile::Base; | ||
| 35 | use Moose; | ||
| 36 | use Module::Load; | ||
| 37 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 38 | =head2 Json | ||
| 39 | |||
| 40 | $json = $app->freeze->Json; | ||
| 41 | $encoded = $json->utf8->encode($data); | ||
| 42 | |||
| 43 | Returns L<JSON> object. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | has 'Json' => ( | ||
| 48 | is => 'rw', | ||
| 49 | isa => 'JSON', | ||
| 50 | lazy => 1, | ||
| 51 | default => sub { | ||
| 52 | load JSON; | ||
| 53 | JSON->new; | ||
| 54 | } | ||
| 55 | ); | ||
| 56 | |||
| 57 | =head2 Yaml | ||
| 58 | |||
| 59 | $yaml = $app->freeze->Yaml; | ||
| 60 | |||
| 61 | Returns L<YAML> object. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | has 'Yaml' => ( | ||
| 66 | is => 'rw', | ||
| 67 | isa => 'YAML', | ||
| 68 | lazy => 1, | ||
| 69 | default => sub { | ||
| 70 | load YAML; | ||
| 71 | YAML->new; | ||
| 72 | } | ||
| 73 | ); | ||
| 74 | |||
| 75 | =head2 Storable | ||
| 76 | |||
| 77 | $json = $app->freeze->Storable; | ||
| 78 | |||
| 79 | Returns "Storable" string. L<Storable> deos not suppot new method. | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | has 'Storable' => ( | ||
| 84 | is => 'ro', | ||
| 85 | lazy => 1, | ||
| 86 | default => sub { | ||
| 87 | load Storable; | ||
| 88 | "Storable"; | ||
| 89 | } | ||
| 90 | ); | ||
| 91 | |||
| 92 | =head2 Dumper | ||
| 93 | |||
| 94 | $dumper = $app->freeze->Dumper; | ||
| 95 | |||
| 96 | Returns L<Data::Dumper> object. | ||
| 97 | |||
| 98 | =cut | ||
| 99 | |||
| 100 | has 'Dumper' => ( | ||
| 101 | is => 'rw', | ||
| 102 | isa => 'Data::Dumper', | ||
| 103 | lazy => 1, | ||
| 104 | default => sub { | ||
| 105 | load Data::Dumper; | ||
| 106 | Data::Dumper->new; | ||
| 107 | } | ||
| 108 | ); | ||
| 109 | |||
| 110 | =head2 Xml | ||
| 111 | |||
| 112 | $xml = $app->freeze->Xml; | ||
| 113 | |||
| 114 | Returns L<XML::TreePP> object. | ||
| 115 | |||
| 116 | =cut | ||
| 117 | |||
| 118 | has 'Xml' => ( | ||
| 119 | is => 'ro', | ||
| 120 | #isa => 'Data::Dumper', | ||
| 121 | lazy => 1, | ||
| 122 | default => sub { | ||
| 123 | load XML::TreePP; | ||
| 124 | XML::TreePP->new; | ||
| 125 | } | ||
| 126 | ); | ||
| 127 | |||
| 128 | |||
| 129 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 130 | |||
| 131 | =pod | ||
| 132 | |||
| 133 | =head1 Bugs | ||
| 134 | |||
| 135 | This project is available on github at L<https://github.com/mewsoft/Nile>. | ||
| 136 | |||
| 137 | =head1 HOMEPAGE | ||
| 138 | |||
| 139 | Please visit the project's homepage at L<https://metacpan.org/release/Nile>. | ||
| 140 | |||
| 141 | =head1 SOURCE | ||
| 142 | |||
| 143 | Source repository is at L<https://github.com/mewsoft/Nile>. | ||
| 144 | |||
| 145 | =head1 SEE ALSO | ||
| 146 | |||
| 147 | See L<Nile> for details about the complete framework. | ||
| 148 | |||
| 149 | =head1 AUTHOR | ||
| 150 | |||
| 151 | Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> | ||
| 152 | Website: http://www.mewsoft.com | ||
| 153 | |||
| 154 | =head1 COPYRIGHT AND LICENSE | ||
| 155 | |||
| 156 | Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, | ||
| 157 | L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com> | ||
| 158 | |||
| 159 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 160 | |||
| 161 | =cut | ||
| 162 | |||
| 163 | 1; |