Mercurial > pub > Impl
view Lib/IMPL/Web/Application/ResourceContract.pm @ 226:b6cde007a175
Added resource contract
author | sergey |
---|---|
date | Wed, 05 Sep 2012 15:10:26 +0400 |
parents | |
children | 70ad6bc20908 |
line wrap: on
line source
package IMPL::Web::Application::ResourceContract; use strict; use IMPL::lang qw(:declare); use IMPL::declare { base => [ 'IMPL::Object' => undef ] }; BEGIN { public property operations => PROP_ALL; private property _namedResources => PROP_ALL; private property _regexpResources => PROP_ALL; } 1; __END__ =pod =head1 NAME C<IMPL::Web::Application::ResourceContract> - описание ресурса =head1 SYNIOSIS =begin code use IMPL::require { ResourceContract => 'IMPL::Web::Application::ResourceContract', OperationContract => 'IMPL::Web::Application::OperationContract' }; my $contract = ResourceContract->new( operations => { get => OperationContract->new( bind => sub { return "Hello!"; } ) }, resources => [ { name => 'info', bind => sub { return $_[0]->model->info; }, contract => ResourceContract->new( get => OperationContract->new( bind => sub { my ($resource,$model) = @_; return $model; # or the same: $resource->model; } ) ) } ] ) =end code =head1 DESCRIPTION =cut