MVC ã®å®ç¾ã®ä»æ¹ï¼ç§ã®å ´åï¼
以ä¸ã®ã¨ã³ããªãæè¦ããã¦é ãã¦ãæã£ãäºã®ã¡ã¢ã
MVCのモデルはDBじゃなくてもいいんだよ - D-6 相変わらず根無し
å人差ããããã¨ã¯æãã¾ãããCatalyst ã使ã£ã¦ããã¨ã C ã®ãã¹ããæ¸ãè¡çºããç§ã¯ããããªã«è¦ã«æããªãããã ãC 㯠URI ãªã½ã¼ã¹ã¨ M ãç¹ãã©ããã¨å²ãåããè¤éãªãã¸ãã¹ãã¸ãã¯ã¯ M ã«æ¼ãä»ããæ¹ããã³ã¼ããã¹ãããªããããM èªä½ãæ±ç¨çã«ã§ãããã
MVCのモデルはDBじゃなくてもいいんだよ - D-6 相変わらず根無し
ãããå ã ã®ãã¯ãã³ã¡ã³ãã®Model::DBICã¯ã©ãããã ãããããªãã®ãããã¿ãããªã¨ããã«è¡ãçããã¨æãã®ã ããããã¯ãããã¢ãã«ã«ãæ ¼ç´å ããæå®ããã®ã«DBãæ½è±¡åããModel::DBICã使ã£ã¦ãããã£ã¦ããæããã
my $c = shift; # Catalystçãªcontextãããã¨ä»®å®ãã¾ã MyApp::Model::BlogEntry->create({ storage => $c->model('DBIC::BlogStorageSchema'), blog => $blog, title => $entry_title, content => $entry_content });ããã§å ¨ãåé¡ãªãDBICã®è¯ãã¨ããã使ããã
Catalyst::Model::Adaptor ã§ã©ããã㦠MyApp::Model::BlogEntry ãä½ããprepare_arguments ãä¸è¨ã®ããã«ããã°ã»ã»ã»
sub prepare_arguments { my ($self, $app) = @_; return { storage => $app->model('DBIC::BlogStorageSchema'), map {$_ => $app->req->param($_)} qw(blog title content), }; }
C ã®ä¸ã§å®éã«ä½¿ãéã«ã¯
$c->model('BlogEntry')->create;
ã§è¡ããããªï¼