Commits

Toby Inkster committed 6b3df14 Draft

minor tidying

Comments (0)

Files changed (2)

lib/Demiblog4/Sugar.pm

 	after_runtime { $caller->meta->make_immutable };
 }
 
+# I actually consider it to be a bug that MooseX-Types doesn't
+# have this overload!
+{
+	package MooseX::Types::TypeDecorator;
+	use overload
+		'~~' => sub {
+			my ($self, $val) = @_;
+			$self->__type_constraint->check($val);
+		};
+}
+
 1;

lib/Demiblog4/Transformer/Graph.pm

 
 handle transform_html ($flavour, $mediatype)
 {	
-	my $style = 'Demiblog4::General';
-	$style = 'Demiblog4::SingleResource'
-		if !ref $ctxt->data_subject;
-	$style = 'Demiblog4::BlogIndex'
-		if ref $ctxt->data_subject eq 'ARRAY';
+	my $style;
+	$style ||= 'Demiblog4::BlogIndex'      if $ctxt->data_subject ~~ ArrayRef;
+	$style ||= 'Demiblog4::SingleResource' if $ctxt->data_subject ~~ UriStr;
+	$style ||= 'Demiblog4::General';       # style of last resort
 	
 	my $entitler = $ctxt->app->entitler;
 	my $title;
 	my $ts_handling;
-	if (ref $ctxt->data_subject eq 'ARRAY')
+	if ($ctxt->data_subject ~~ ArrayRef)
 	{
-		$ts_handling = !!1;
+		$ts_handling = true;
 		$title = 'Blog';
 	}
 	else
 	{
-		$ts_handling = !!0;
+		$ts_handling = false;
 		$title =
 			$entitler->title(RDF::Trine::Node::Resource::->new($ctxt->data_subject))
 			// $ctxt->data_subject;