1 |
package Frey; |
package Frey; |
2 |
use Moose; |
use Moose; |
3 |
|
|
4 |
|
our $VERSION = "0.23"; |
5 |
|
|
6 |
|
use Data::Dump qw//; |
7 |
|
sub dump { Data::Dump::dump ( @_ ) } |
8 |
|
|
9 |
has 'debug' => ( |
has 'debug' => ( |
10 |
is => 'rw', |
is => 'rw', |
11 |
isa => 'Bool', |
isa => 'Int', |
12 |
default => 1, |
default => 0, |
13 |
); |
); |
14 |
|
|
15 |
=head1 NAME |
=head1 NAME |
23 |
The Norse god who dispenses peace, good weather, prosperity, and bountiful |
The Norse god who dispenses peace, good weather, prosperity, and bountiful |
24 |
crops; the brother of Freya. |
crops; the brother of Freya. |
25 |
|
|
26 |
=cut |
Basically you write L<Moose> classes which become deirectly callable from |
27 |
|
the web using REST API |
28 |
|
|
29 |
use Data::Dump qw/dump/; |
=head1 INTROSPECTION |
|
use File::Find; |
|
30 |
|
|
31 |
has 'classes' => ( |
Secondary goal is to have introspection. |
32 |
is => 'ro', |
|
33 |
# isa => 'HashRef[Str]', |
=head2 Moose classes |
34 |
default => sub { |
|
35 |
my $self = shift; |
All Moose classes have simple introspection API which use |
36 |
# FIXME there must be better way to do this in Moose style |
L<Frey::Introspect> to show class and it's pod (using L<Frey::Pod>). |
37 |
my $classes; |
|
38 |
finddepth({ no_chdir => 1, wanted => sub { |
Example of valid REST URL is |
39 |
return unless s/\.pm$//; |
|
40 |
my @a = split(m!/!,$_); |
http://localhost:16001/Frey |
41 |
if ( $#a != 2 ) { |
|
42 |
warn "SKIP $_ [$#a]" if $self->debug; |
which will show L<Frey> class introspection. |
43 |
return; |
|
44 |
} |
You can also add method invocation and optonal parametars to C<new> |
45 |
warn ">> $_ ",dump( @a ) if $self->debug; |
constructor like this: |
46 |
my $package = "$a[1]::$a[2]"; |
|
47 |
warn "## $package\n"; |
http://localhost:16001/Frey::Pod/as_markup?class=Frey |
48 |
push @$classes, { $package => "$_.pm" }; |
|
49 |
} }, 'lib'); |
this is same using L<Frey::Pod> from perl as |
50 |
warn "## classes = ",dump( $classes ) if $self->debug; |
|
51 |
$classes; |
Frey::Pod->new( class => 'Frey' )->as_markup; |
52 |
}, |
|
53 |
lazy => 1, |
if you leave out parametars, L<Frey::Run> will ask for required ones. |
54 |
); |
|
55 |
|
=head2 Database |
56 |
|
|
57 |
|
For database objects we support L<Fey> and when your objects are created |
58 |
|
C<< with 'Frey::Collection' >> they will have basic CRUD functionality |
59 |
|
implemented by L<Frey::ObjectBrowser>. |
60 |
|
|
61 |
|
=cut |
62 |
|
|
63 |
1; |
1; |