diff options
Diffstat (limited to 'perllib')
21 files changed, 55 insertions, 70 deletions
diff --git a/perllib/FixMyStreet/Cobrand.pm b/perllib/FixMyStreet/Cobrand.pm index ff7d7f943..9f61635d8 100644 --- a/perllib/FixMyStreet/Cobrand.pm +++ b/perllib/FixMyStreet/Cobrand.pm @@ -8,7 +8,7 @@ use warnings; use FixMyStreet; use Carp; -use Moose; +use Package::Stash; use Module::Pluggable sub_name => '_cobrands', @@ -77,11 +77,12 @@ sub available_cobrand_classes { sub class { my $avail = shift; return $avail->{class} if $avail->{class}; - my $moniker = $avail->{moniker}; - Class::MOP::Class->create("FixMyStreet::Cobrand::$moniker" => ( - superclasses => [ 'FixMyStreet::Cobrand::Default' ], - )); - return "FixMyStreet::Cobrand::$moniker"; + my $moniker = "FixMyStreet::Cobrand::$avail->{moniker}"; + my $class = bless {}, $moniker; + my $stash = Package::Stash->new($moniker); + my $isa = $stash->get_or_add_symbol('@ISA'); + @{$isa} = ('FixMyStreet::Cobrand::Default'); + return $moniker; } =head2 get_class_for_host diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm index 35cce8368..2a52a7bca 100644 --- a/perllib/FixMyStreet/DB/Result/Alert.pm +++ b/perllib/FixMyStreet/DB/Result/Alert.pm @@ -70,7 +70,7 @@ __PACKAGE__->belongs_to( # You can replace this text with custom code or comments, and it will be preserved on regeneration -use Moose; +use Moo; use namespace::clean -except => [ 'meta' ]; with 'FixMyStreet::Roles::Abuser'; @@ -113,7 +113,4 @@ sub disable { return 1; } -# need the inline_constuctor bit as we don't inherit from Moose -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); - 1; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 04493b5b5..41e8cf315 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -96,7 +96,7 @@ __PACKAGE__->belongs_to( __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); -use Moose; +use Moo; use Utils::Photo; use namespace::clean -except => [ 'meta' ]; @@ -214,7 +214,4 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 1 }, ); -# we need the inline_constructor bit as we don't inherit from Moose -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); - 1; diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index 2fbb0716d..dab5432c6 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -63,12 +63,9 @@ __PACKAGE__->belongs_to( __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); -use Moose; +use Moo; use namespace::clean -except => [ 'meta' ]; with 'FixMyStreet::Roles::Extra'; -# we need the inline_constructor bit as we don't inherit from Moose -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); - 1; diff --git a/perllib/FixMyStreet/DB/Result/Nearby.pm b/perllib/FixMyStreet/DB/Result/Nearby.pm index d3d228788..adeba703a 100644 --- a/perllib/FixMyStreet/DB/Result/Nearby.pm +++ b/perllib/FixMyStreet/DB/Result/Nearby.pm @@ -6,7 +6,7 @@ use strict; use warnings; use base 'DBIx::Class::Core'; -use Moose; +use Moo; use namespace::clean -except => [ 'meta' ]; __PACKAGE__->table( 'NONE' ); @@ -27,7 +27,4 @@ __PACKAGE__->belongs_to( __PACKAGE__->result_source_instance ->name( \'problem_find_nearby(?,?,?)' ); -# we need the inline_constructor bit as we don't inherit from Moose -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); - 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index e340acf1e..5c4511268 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -157,7 +157,7 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); __PACKAGE__->rabx_column('geocode'); -use Moose; +use Moo; use namespace::clean -except => [ 'meta' ]; use Utils; use Utils::Photo; @@ -891,7 +891,4 @@ sub get_time_spent { return $admin_logs ? $admin_logs->get_column('sum_time_spent') : 0; } -# we need the inline_constructor bit as we don't inherit from Moose -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); - 1; diff --git a/perllib/FixMyStreet/DB/Result/Questionnaire.pm b/perllib/FixMyStreet/DB/Result/Questionnaire.pm index 6f2941546..30f2ab7ce 100644 --- a/perllib/FixMyStreet/DB/Result/Questionnaire.pm +++ b/perllib/FixMyStreet/DB/Result/Questionnaire.pm @@ -43,7 +43,7 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oL1Hk4/bNG14CY74GA75SA -use Moose; +use Moo; use namespace::clean -except => [ 'meta' ]; my $stz = sub { diff --git a/perllib/FixMyStreet/Roles/Abuser.pm b/perllib/FixMyStreet/Roles/Abuser.pm index b9e951305..fc76565ca 100644 --- a/perllib/FixMyStreet/Roles/Abuser.pm +++ b/perllib/FixMyStreet/Roles/Abuser.pm @@ -1,6 +1,6 @@ package FixMyStreet::Roles::Abuser; -use Moose::Role; +use Moo::Role; =head2 is_from_abuser diff --git a/perllib/FixMyStreet/Roles/Extra.pm b/perllib/FixMyStreet/Roles/Extra.pm index f815a3e9a..19fc91873 100644 --- a/perllib/FixMyStreet/Roles/Extra.pm +++ b/perllib/FixMyStreet/Roles/Extra.pm @@ -1,5 +1,5 @@ package FixMyStreet::Roles::Extra; -use Moose::Role; +use Moo::Role; =head1 NAME @@ -9,12 +9,9 @@ FixMyStreet::Roles::Extra - role for accessing {extra} field This is to applied to a DB class like Problem or Contacts that has a rich {extra} field: - use Moose; + use Moo; with 'FixMyStreet::Roles::Extra'; -(NB: there is actually a little more boilerplate, because DBIC doesn't actually -inherit from Moose, see ::Problem for an example.) - Then: $contact->set_extra_fields( diff --git a/perllib/FixMyStreet/SendReport.pm b/perllib/FixMyStreet/SendReport.pm index 9967b0663..40ec4caf2 100644 --- a/perllib/FixMyStreet/SendReport.pm +++ b/perllib/FixMyStreet/SendReport.pm @@ -1,20 +1,21 @@ package FixMyStreet::SendReport; -use Moose; +use Moo; +use MooX::Types::MooseLike::Base qw(:all); use Module::Pluggable sub_name => 'senders', search_path => __PACKAGE__, require => 1; -has 'body_config' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); -has 'bodies' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); -has 'to' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); -has 'bcc' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); -has 'success' => ( is => 'rw', isa => 'Bool', default => 0 ); -has 'error' => ( is => 'rw', isa => 'Str', default => '' ); -has 'unconfirmed_counts' => ( 'is' => 'rw', isa => 'HashRef', default => sub { {} } ); -has 'unconfirmed_notes' => ( 'is' => 'rw', isa => 'HashRef', default => sub { {} } ); +has 'body_config' => ( is => 'rw', isa => HashRef, default => sub { {} } ); +has 'bodies' => ( is => 'rw', isa => ArrayRef, default => sub { [] } ); +has 'to' => ( is => 'rw', isa => ArrayRef, default => sub { [] } ); +has 'bcc' => ( is => 'rw', isa => ArrayRef, default => sub { [] } ); +has 'success' => ( is => 'rw', isa => Bool, default => 0 ); +has 'error' => ( is => 'rw', isa => Str, default => '' ); +has 'unconfirmed_counts' => ( 'is' => 'rw', isa => HashRef, default => sub { {} } ); +has 'unconfirmed_notes' => ( 'is' => 'rw', isa => HashRef, default => sub { {} } ); sub should_skip { diff --git a/perllib/FixMyStreet/SendReport/EastHants.pm b/perllib/FixMyStreet/SendReport/EastHants.pm index 44bc084b1..697519b48 100644 --- a/perllib/FixMyStreet/SendReport/EastHants.pm +++ b/perllib/FixMyStreet/SendReport/EastHants.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::EastHants; -use Moose; +use Moo; BEGIN { extends 'FixMyStreet::SendReport'; } diff --git a/perllib/FixMyStreet/SendReport/Email.pm b/perllib/FixMyStreet/SendReport/Email.pm index bc526ded2..3e993ecd6 100644 --- a/perllib/FixMyStreet/SendReport/Email.pm +++ b/perllib/FixMyStreet/SendReport/Email.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Email; -use Moose; +use Moo; use FixMyStreet::Email; BEGIN { extends 'FixMyStreet::SendReport'; } diff --git a/perllib/FixMyStreet/SendReport/EmptyHomes.pm b/perllib/FixMyStreet/SendReport/EmptyHomes.pm index bf7164e21..a4cdd3e40 100644 --- a/perllib/FixMyStreet/SendReport/EmptyHomes.pm +++ b/perllib/FixMyStreet/SendReport/EmptyHomes.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::EmptyHomes; -use Moose; +use Moo; use namespace::autoclean; use mySociety::MaPit; diff --git a/perllib/FixMyStreet/SendReport/Noop.pm b/perllib/FixMyStreet/SendReport/Noop.pm index f2e0a3bdb..60edda373 100644 --- a/perllib/FixMyStreet/SendReport/Noop.pm +++ b/perllib/FixMyStreet/SendReport/Noop.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Noop; -use Moose; +use Moo; BEGIN { extends 'FixMyStreet::SendReport'; } diff --git a/perllib/FixMyStreet/SendReport/Open311.pm b/perllib/FixMyStreet/SendReport/Open311.pm index 14dd65fa6..1917c2f58 100644 --- a/perllib/FixMyStreet/SendReport/Open311.pm +++ b/perllib/FixMyStreet/SendReport/Open311.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Open311; -use Moose; +use Moo; use namespace::autoclean; BEGIN { extends 'FixMyStreet::SendReport'; } diff --git a/perllib/FixMyStreet/SendReport/Refused.pm b/perllib/FixMyStreet/SendReport/Refused.pm index d71fc5c2c..c6c1a660d 100644 --- a/perllib/FixMyStreet/SendReport/Refused.pm +++ b/perllib/FixMyStreet/SendReport/Refused.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Refused; -use Moose; +use Moo; BEGIN { extends 'FixMyStreet::SendReport::Noop'; } diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm index 7af4cf4f5..a8730bbe4 100644 --- a/perllib/FixMyStreet/SendReport/Zurich.pm +++ b/perllib/FixMyStreet/SendReport/Zurich.pm @@ -1,6 +1,6 @@ package FixMyStreet::SendReport::Zurich; -use Moose; +use Moo; BEGIN { extends 'FixMyStreet::SendReport::Email'; } diff --git a/perllib/Open311.pm b/perllib/Open311.pm index db6fcc4a8..e500219bc 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -2,7 +2,8 @@ package Open311; use utf8; use URI; -use Moose; +use Moo; +use MooX::Types::MooseLike::Base qw(:all); use XML::Simple; use LWP::Simple; use LWP::UserAgent; @@ -11,24 +12,24 @@ use HTTP::Request::Common qw(POST); use FixMyStreet::Cobrand; use FixMyStreet::DB; -has jurisdiction => ( is => 'ro', isa => 'Str' );; -has api_key => ( is => 'ro', isa => 'Str' ); -has endpoint => ( is => 'ro', isa => 'Str' ); -has test_mode => ( is => 'ro', isa => 'Bool' ); -has test_uri_used => ( is => 'rw', 'isa' => 'Str' ); +has jurisdiction => ( is => 'ro', isa => Str );; +has api_key => ( is => 'ro', isa => Str ); +has endpoint => ( is => 'ro', isa => Str ); +has test_mode => ( is => 'ro', isa => Bool ); +has test_uri_used => ( is => 'rw', 'isa' => Str ); has test_req_used => ( is => 'rw' ); has test_get_returns => ( is => 'rw' ); has endpoints => ( is => 'rw', default => sub { { services => 'services.xml', requests => 'requests.xml', service_request_updates => 'servicerequestupdates.xml', update => 'servicerequestupdates.xml' } } ); -has debug => ( is => 'ro', isa => 'Bool', default => 0 ); -has debug_details => ( is => 'rw', 'isa' => 'Str', default => '' ); -has success => ( is => 'rw', 'isa' => 'Bool', default => 0 ); -has error => ( is => 'rw', 'isa' => 'Str', default => '' ); -has always_send_latlong => ( is => 'ro', isa => 'Bool', default => 1 ); -has send_notpinpointed => ( is => 'ro', isa => 'Bool', default => 0 ); -has extended_description => ( is => 'ro', isa => 'Str', default => 1 ); -has use_service_as_deviceid => ( is => 'ro', isa => 'Bool', default => 0 ); -has use_extended_updates => ( is => 'ro', isa => 'Bool', default => 0 ); -has extended_statuses => ( is => 'ro', isa => 'Bool', default => 0 ); +has debug => ( is => 'ro', isa => Bool, default => 0 ); +has debug_details => ( is => 'rw', 'isa' => Str, default => '' ); +has success => ( is => 'rw', 'isa' => Bool, default => 0 ); +has error => ( is => 'rw', 'isa' => Str, default => '' ); +has always_send_latlong => ( is => 'ro', isa => Bool, default => 1 ); +has send_notpinpointed => ( is => 'ro', isa => Bool, default => 0 ); +has extended_description => ( is => 'ro', isa => Str, default => 1 ); +has use_service_as_deviceid => ( is => 'ro', isa => Bool, default => 0 ); +has use_extended_updates => ( is => 'ro', isa => Bool, default => 0 ); +has extended_statuses => ( is => 'ro', isa => Bool, default => 0 ); before [ qw/get_service_list get_service_meta_info get_service_requests get_service_request_updates diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm index b7da43604..6d846de42 100644 --- a/perllib/Open311/GetServiceRequestUpdates.pm +++ b/perllib/Open311/GetServiceRequestUpdates.pm @@ -1,13 +1,13 @@ package Open311::GetServiceRequestUpdates; -use Moose; +use Moo; use Open311; use FixMyStreet::DB; use DateTime::Format::W3CDTF; has system_user => ( is => 'rw' ); -has start_date => ( is => 'ro', default => undef ); -has end_date => ( is => 'ro', default => undef ); +has start_date => ( is => 'ro', default => sub { undef } ); +has end_date => ( is => 'ro', default => sub { undef } ); has suppress_alerts => ( is => 'rw', default => 0 ); has verbose => ( is => 'ro', default => 0 ); has schema => ( is =>'ro', lazy => 1, default => sub { FixMyStreet::DB->connect } ); diff --git a/perllib/Open311/GetUpdates.pm b/perllib/Open311/GetUpdates.pm index afbdd13b5..901e78809 100644 --- a/perllib/Open311/GetUpdates.pm +++ b/perllib/Open311/GetUpdates.pm @@ -1,6 +1,6 @@ package Open311::GetUpdates; -use Moose; +use Moo; use Open311; use FixMyStreet::Cobrand; diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index fbb0ebc56..f251606cf 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -1,6 +1,6 @@ package Open311::PopulateServiceList; -use Moose; +use Moo; use Open311; has bodies => ( is => 'ro' ); |