This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(my $upload = $self->req->upload('myfile')) { | |
my $filename = $upload->filename; | |
my $asset; | |
if(ref($upload->asset) ne 'Mojo::Upload::File') { | |
$asset = Mojo::Asset::File->new(path => POSIX::tmpnam); | |
$asset->add_chunk($upload->asset->slurp); | |
} else { | |
$asset = $upload->asset; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$self->objectmanager->add_sub_for( | |
object => $object_type, | |
object_method => $method_name, | |
method => sub { | |
if(my $m = shift->app->jsp->can($method_name)) { | |
return $m->(@_); | |
} | |
}, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach my $object_type ($self->objectmanager->registered_types) { | |
$self->objectmanager->meta_for($object_type => Moose::Meta::Class->create( | |
'App::Object::' . $object_type, | |
{ | |
methods => $self->objectmanager->get_methods_for($object_type), | |
attributes => $self->objectmanager->get_attributes_for($object_type), | |
superclasses => ['App::Object'], | |
roles => [ 'App::Object::Generated', $self->objectmanager->roles_for($object_type) ], | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ref($_) eq 'HASH" && defined($_->{'$id'}) && defined($_->{'$ref'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has 'foo' => (is => 'rw', isa => 'DBref[Object::Foo]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Moose::Util::TypeConstraints; | |
use Moose::Util (); | |
my $TYPE_REGISTRY = Moose::Util::TypeConstraints->get_type_constraint_registry; | |
$TYPE_REGISTRY->add_type_constraint( | |
Moose::Meta::TypeConstraint::Parameterizable->new( | |
name => 'DBref', | |
package_defined_in => __PACKAGE__, | |
parent => Moose::Util::TypeConstraints::find_type_constraint('Item'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myClass = new MooseClassFactory() | |
.name('MyMooseClass') | |
.with(['SomeRandomRole', 'SomeOtherRole' ]) | |
.extends('MyOtherMooseClass') | |
.has('foo', { is: 'ro', isa: 'Str', required: true }) | |
.has('bar', { is: 'rw', isa: 'Str', required: true, defaultValue: function() { return "foo " + " bar" } }) | |
.method('fweep', function() { | |
say("fweeping up a storm!"); | |
}) | |
.makeImmutable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dumpAttributes(aMooseClass) { | |
aMooseClass.meta().get_all_attributes().forEach(function(attr) { | |
say("aMooseClass has attribute: ", attr.name()); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
package Foobar; | |
use Moose; | |
use JSPL; | |
use Try::Tiny qw/catch try/; | |
has 'foo' => (is => 'rw', isa => 'Num', required => 1, reader => 'get_foo', writer => 'set_foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package WR::Parser::LL; | |
use strict; | |
use Moose; | |
use namespace::autoclean; | |
use IO::String; | |
=pod | |
=head1 ABSTRACT |