]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/Model/Base.pm
Added Maypole::Model::Base::is_public()
[maypole.git] / lib / Maypole / Model / Base.pm
index 804f23519d0a808b1000d621660fe2b010d4f0fc..b592eaab30f9439d257a2a04df8775c6a504d7e7 100644 (file)
@@ -1,5 +1,10 @@
 package Maypole::Model::Base;
+
+use Maypole::Constants;
+use attributes ();
+
 our %remember;
+
 sub MODIFY_CODE_ATTRIBUTES { $remember{ $_[1] } = $_[2]; () }
 
 sub FETCH_CODE_ATTRIBUTES { $remember{ $_[1] } }
@@ -147,5 +152,16 @@ A description of the class to be passed to the template.
 
 sub description { "A poorly defined class" }
 
-1;
+sub is_public {
+    my ( $self, $action ) = @_;
+    my $cv = $self->can($action);
+    return DECLINED() unless $cv;
+    my $attrs = join " ", attributes::get($cv);
+    do {
+        warn "$action not exported" if Maypole->debug;
+        return DECLINED();
+    } unless $attrs =~ /\bExported\b/i;
+    return OK;
+}
 
+1;