[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[6543] trunk/LedgerSMB/Request.pm
- Subject: SF.net SVN: ledger-smb:[6543] trunk/LedgerSMB/Request.pm
- From: ..hidden..
- Date: Sun, 19 Jan 2014 07:59:17 +0000
Revision: 6543
http://sourceforge.net/p/ledger-smb/code/6543
Author: einhverfr
Date: 2014-01-19 07:59:15 +0000 (Sun, 19 Jan 2014)
Log Message:
-----------
first attempt at a requires_from api for pulling in required attributes from Moose class
Modified Paths:
--------------
trunk/LedgerSMB/Request.pm
Modified: trunk/LedgerSMB/Request.pm
===================================================================
--- trunk/LedgerSMB/Request.pm 2014-01-19 04:50:50 UTC (rev 6542)
+++ trunk/LedgerSMB/Request.pm 2014-01-19 07:59:15 UTC (rev 6543)
@@ -23,6 +23,7 @@
use LedgerSMB::App_State;
use LedgerSMB::PGNumber;
use LedgerSMB::PGDate;
+use Carp;
=head1 DESCRIPTION
@@ -68,6 +69,25 @@
}
}
+=head2 requires_from($moose_class_name)
+
+Assumes one is goin to instantiate a Moose class with the object and checks for
+required attributes on the Moose class.
+
+=cut
+
+sub requires_from {
+ no strict 'refs';
+ my ($self, $class) = @_;
+ my $meta;
+ eval { $meta = $class->meta }
+ or Carp::croak
+ "Could not get meta object. Is $class a valid Moose class?";
+ for my $att($meta->get_attibute_list){
+ $self->require($att) if $meta->get_attribute($_)->required;
+ }
+}
+
=head2 numbers(@attnames)
Transforms every $self->{$attname} into a LedgerSMB::PGNumber instance based on
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits