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