Permalink
Browse files

working on HO v.06 part one

git-svn-id: http://sknpp.unfuddle.com/svn/sknpp_sknpp/Recipe@24 63df29d3-4323-0410-adbf-b7f0d5065d14
  • Loading branch information...
1 parent a77efaf commit f24964202e34a7201bba6d66261965392fcf0a30 sknpp_ftr committed Jul 7, 2007
Showing with 26 additions and 19 deletions.
  1. +26 −15 lib/Recipe/Object.pm
  2. +0 −4 lib/Recipe/Std/Person.pm
View
@@ -5,7 +5,7 @@
; use strict; use warnings; use utf8
; use Carp
-; use Params::Smart ()
+; require Params::Smart '0.04'
; use Sub::Install 'install_sub'
; use Data::Dumper
@@ -23,6 +23,13 @@
}
#######################################################################
+; use base 'Class::Accessor::Fast'
+; __PACKAGE__->mk_accessors
+ ( 'validator' # a coderef produced by Params::Smart
+ , 'condiment' # the given condiments as array ref
+ , 'pkg_sub' # which method we build
+ )
+
# create somthing in the derived class
; sub init
{ #print "Init: ".Dumper([@_])
@@ -34,35 +41,39 @@
; my @params =@_
; local $Carp::CarpLevel=3
- ; if( @params==0 )
- { carp "nothing happens without a argument. Maybe in a future version\n"
- ,"is this the way to uninstall a method."
- ; return
- }
+ #; if( @params==0 )
+ # { carp "nothing happens without a argument. Maybe in a future version\n"
+ # ,"is this the way to uninstall a method."
+ # ; return
+ # }
; # ok die Daten sollten in einer geigneten Struktur gespeichert werden
# dafür sollte $class verantwortlich sein
# fr den Anfang sollte es gengen wenn ich mit Class::Struct und
# Params::Smart beginne.
- ; my $subpkg = "${class}::${type}"
+ ; my $subpkg = "${type}::${method}"
; my $self={name => 'self',position => 0, required => 1}
; my @template=($self,map { ref $params[$_]
? $params[$_]
: { name => $params[$_], position => $_+1 }
} 0..$#params )
; my $sub = sub
- { return bless([@_,@params],$subpkg) if @_==1
- ; my %args = Params($subpkg,@template)->args(@_)
-# ; print Dumper(\%args)
- ; $args{self}
+ { # produces a validated %args hash
+ ; Params($subpkg,@template)->args(@_)
}
- ; debug "Install $method in class $class with signatur:",Dumper('self',@params)
- ; install_sub({ code => $sub, into => $class, as => $method });
+
+ # create a fresh Recipe::Object
+ ; $class->new
+ ({ condiments => [@params]
+ , validator => $sub
+ , pkg_sub => $subpkg
+ })
}
+# Installation is sceduled for later.
+# ; debug "Install $method in class $class with signatur:",Dumper('self',@params)
+# ; install_sub({ code => $sub, into => $class, as => $method });
-; sub new
- { bless {}, shift() }
; 1
View
@@ -19,7 +19,3 @@
__END__
-# Das kann nicht direkt in der Factory::Person stehen
-# weil das verwendete eval zum Laden nicht sehr Carpfreundlich ist.
-# Man bekommt nicht Fehler in Zeile sowieso, sondern in eval line 5
-# irgendwas.

0 comments on commit f249642

Please sign in to comment.