From aba1aabb2489c25080c89c35449db9c34a61bb55 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 22 Feb 2011 00:52:51 -0600 Subject: new ox syntax --- lib/Narwhal.pm | 64 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/lib/Narwhal.pm b/lib/Narwhal.pm index b78e514..121cd2c 100644 --- a/lib/Narwhal.pm +++ b/lib/Narwhal.pm @@ -4,36 +4,54 @@ use OX; with 'OX::Role::WithAppRoot'; has kioku_dsn => ( - traits => ['OX::Config'], - is => 'ro', - isa => 'Str', - default => 'dbi:SQLite:narwhal.db', + is => 'ro', + isa => 'Str', + value => 'dbi:SQLite:narwhal.db', ); -config kioku_extra_args => sub { { create => 1 } }; -config template_root => sub { - shift->param('app_root')->subdir('root', 'templates') -}, (app_root => depends_on('/app_root')); +has kioku_extra_args => ( + is => 'ro', + isa => 'HashRef', + block => sub { { create => 1 } }, +); + +has template_root => ( + is => 'ro', + isa => 'Str', + block => sub { shift->param('app_root')->subdir('root', 'templates') }, + dependencies => ['app_root'], +); -component Redirect => 'Narwhal::Component::Redirect'; +has redirect => ( + is => 'ro', + isa => 'Narwhal::Component::Redirect', +); -component Wiki => 'Narwhal::Component::Wiki', ( - kioku => depends_on('/Component/Kioku'), - tt => depends_on('/Component/TT'), +has wiki => ( + is => 'ro', + isa => 'Narwhal::Component::Wiki', + dependencies => ['kioku', 'tt'], ); -component WikiEdit => 'Narwhal::Component::Wiki::Edit', ( - kioku => depends_on('/Component/Kioku'), - tt => depends_on('/Component/TT'), +has wiki_edit => ( + is => 'ro', + isa => 'Narwhal::Component::Wiki::Edit', + dependencies => ['kioku', 'tt'], ); -component TT => 'OX::View::TT', ( - template_root => depends_on('/Config/template_root'), +has tt => ( + is => 'ro', + isa => 'OX::View::TT', + dependencies => ['template_root'], ); -component Kioku => 'Narwhal::Component::Model', ( - dsn => depends_on('/Config/kioku_dsn'), - extra_args => depends_on('/Config/kioku_extra_args'), +has kioku => ( + is => 'ro', + isa => 'Narwhal::Component::Model', + dependencies => { + dsn => 'kioku_dsn', + extra_args => 'kioku_extra_args', + }, ); router ['Narwhal::RouteBuilder::HTTPMethod'], as { @@ -54,9 +72,9 @@ router ['Narwhal::RouteBuilder::HTTPMethod'], as { page_name => { isa => 'Str' }, ); }, ( - redirect => depends_on('/Component/Redirect'), - wiki => depends_on('/Component/Wiki'), - edit => depends_on('/Component/WikiEdit'), + redirect => depends_on('redirect'), + wiki => depends_on('wiki'), + edit => depends_on('wiki_edit'), ); no OX; -- cgit v1.2.3