Oryx

Meta-Model Driven Object Persistance with Multiple Inheritance
Download

Oryx Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Richard Hundt
  • Publisher web site:
  • http://search.cpan.org/~rhundt/

Oryx Tags


Oryx Description

Meta-Model Driven Object Persistance with Multiple Inheritance Oryx is an object persistence framework which supports both object-relational mapping as well as DMB style databases and as such is not coupled with any particular storage back-end. In other words, you should be able to swap out an RDMBS with a DBM style database (and vice versa) without changing your persistent classes at all.This is achieved with the use a meta model which fits in as closely with Perl's own as possible - and due to Perl's excellent introspection capabilities and enormous flexibility - this is very close indeed. For this reason Hash, Array and Reference association types are implemented with liberal use of `tie'. The use of a meta model, albeit a very transparent one, conceptually supports the de-coupling of storage back-end from persistent classes, and, for the most part, beside a really small amout of meta-data, you would use persistent classes in a way that is virtually indistinguishable from ordinary perl classes.Oryx follows the DRY principle - Don't Repeat Yourself - inspired by the fantastic Ruby on Rails framework, so what you do say, you say it only once when defining your $schema for your class. After that, everything is taken care of for you, including automatic table creation (if you're using an RDBMS storage). Oryx attempts to name tables and link tables created in this way sensibly, so that if you need to you should be able to find your way around in the schema with ease.Because Oryx implements relationships as ordinary Perl Array and Hash references, you can create any structures or object relationships that you could create in native Perl and have these persist in a database. This gives you the flexibility to create trees, cyclic structures, linked lists, mixed lists (lists with instances of different classes), etc.Oryx also supports multiple inheritance by Perl's native use base mechanism. Abstract classes, which are simply classes with no attributes, are meaningful too.SYNOPSIS # define a persistent class package CMS::Page; use base qw(Oryx::Class); our $schema = { attributes => , associations => }; 1; # ... for more details see DEFINING CLASS META-DATA in L) #=========================================================================== # use a persistent class use CMS::Page; $page = CMS::Page->create({title => 'Life in the Metaverse'}); $page = CMS::Page->retrieve($id); $page->update; $page->delete; @pages = CMS::Page->search({author => 'Richard Hun%'}, @order, $limit, $offset); # search with SQL WHERE clause (which pages contain a particular paragraph): @book = CMS::Page->search({ EXISTS => q{( SELECT id FROM page WHERE page.id = author.id AND page.title LIKE 'Meta%' )} }); #=========================================================================== # commit your changes $page->commit; #=========================================================================== # attribute mutator $page->title('The Metamanic Mechanic'); $tite = $page->title; #=========================================================================== # reference association mutator $template_obj = $page->template; $page->template( $template_obj ); #=========================================================================== # array association accessor $page->paragraphs-> = $intro_para; $paragraph = $page->paragraphs->; #=========================================================================== # array association operators $concl = pop @{$page->paragraphs}; $intro = shift @{$page->paragraphs}; push @{$page->paragraphs}, $concl; unshift @{$page->paragraphs}, $new_intro; splice @{$page->paragraphs}, 1, 4, ($summary); #=========================================================================== # hash association accessor $image_obj = $page->images->{logo}; $page->images->{mug_shot} = $my_ugly_mug; @keys = keys %{$page->images}; @values = values %{$page->images}; #=========================================================================== # support for Class::Observable Page->add_observer(sub { my ($item, $action) = @_; #... }); $page->add_observer(...); # instance #=========================================================================== # connect to storage $storage = Oryx->connect(); # or specify a schema $storage = Oryx->connect( , 'CMS::Schema' ); # for DBM::Deep back-end Oryx->connect(, 'CMS::Schema'); #=========================================================================== # deploy the schema $storage->deploySchema(); # for all known classes (via `use') $storage->deploySchema('CMS::Schema'); $storage->deployClass('CMS::Page'); # automatically deploy as needed use Oryx ( auto_deploy => 1 ); # for all classes CMS::Page->auto_deploy(1); # only for this class Requirements: · Perl


Oryx Related Software