Hydrate Perl 6 module
Perl6
Switch branches/tags
Nothing to show
Latest commit b8e596b Apr 25, 2017 @vendethiel committed on GitHub Merge pull request #1 from zoffixznet/patch-1
Use modern META filename
Permalink
Failed to load latest commit information.
lib decontainerize Aug 10, 2016
t correct the files to send Nov 14, 2015
META6.json Use modern META filename Apr 25, 2017
README.md correct the files to send Nov 14, 2015

README.md

Hydrate

Hydrate is a small module to "hydrate" (ORM speak) your object hierarchy, from a bunch of hashes.

Example:

use Hydrate;

my class Mes {
  has Int $.height;
  has Int $.width;
}

my class Cont {
  has Str $.name is required;
  has Mes @.mesures;
  has %.data; # optional 
}

say hydrate(Cont, {
  name => "Some mesures",
  mesures => [
    {height => 50,  width => 50},
    {height => 150, width => 75},
    {height => 200, width => 200},
  ]
})

Result:

Cont.new(
  name => "Some mesures",
  mesures => Array[Mes].new(
    Mes.new(height => 50, width => 50),
    Mes.new(height => 150, width => 75),
    Mes.new(height => 200, width => 200)
  ),
  data => {},
)