Commit | Line | Data |
61ef2dee |
1 | package SomeModelClassInterface; |
2 | use Moose::Role; |
3 | use namespace::autoclean; |
4 | |
5 | requires 'say_hello'; |
6 | |
7d26c84b |
7 | package SomeModelClass; |
8 | use Moose; |
8c228ad4 |
9 | use CatalystX::ControllerGeneratingModel; |
d7bd7765 |
10 | use DemoTypeLibrary qw/MessageDocument/; |
11 | use MooseX::Lexical::Types qw/MessageDocument/; |
046d763d |
12 | use namespace::autoclean; |
7d26c84b |
13 | |
14 | # Note trivial calling convention. |
15 | # Apply MX::Method::Signatures and MX::Types::Structured to be less lame. |
16 | |
17 | # Introspection should only reflect methods which satisfy the calling convention |
18 | # This is left as an exercise to the reader. :) |
19 | |
d7bd7765 |
20 | # Note command syntax not actually needed, this could be a normal sub, |
21 | # but doing so makes the eventual merge harder.. |
22 | |
8c228ad4 |
23 | command say_hello => sub { |
d7bd7765 |
24 | my ($self, $document) = @_; |
25 | |
26 | my $name = $document->{name}; |
27 | return({ type => 'say_hello_response', |
28 | |
29 | body => "Hello $name" }); |
8c228ad4 |
30 | }; |
7d26c84b |
31 | |
61ef2dee |
32 | with 'SomeModelClassInterface'; |
33 | |
d7bd7765 |
34 | before 'say_hello' => sub { |
35 | my $self = shift; |
36 | my MessageDocument $message = shift; |
37 | }; |
38 | |
7d26c84b |
39 | __PACKAGE__->meta->make_immutable; |
40 | |