NAME

WebService::ProfitBricks::Class - Class helper functions

DESCRIPTION

This is a module exporting some helper functions to ease the creation of objects.

SYNOPSIS

package My::Pkg;
use WebService::ProfitBricks::Class;
    
has_many foo    => "My::Foo";
belongs_to file => "My::File";
   
# the constructor, to extend the provided constructor.
sub construct {
   my ($self, @data) = @_;
}
    

EXPORTED FUNCTIONS

new(%data)

A common constructor. It accepts an hash (key, values pairs) and stores this hash. If you need to do more, you can create a function construct.

has_many($what, $class, $options)

Create a relations to $class over $what.

belongs_to($what, $class, $options)

Creates a backward relaion to $class.

does($what, $option)
attr($attr, $option)

Create a class attribute $attr.

attrs(@attributes)

Create multiple attributes for the class.

serializer($type, $options)

Sets a serializer for the class.

This will create a method $class->to_$type([%data]).