Brian and I came up with the idea of KWID (KWiki Inline Documentation) a while back. Today, after a pile of successful testing & coding, I sat back and thought, "After the deadline I'm gonna have to document all of this." Then it dawned on me that the documentation was all there!
I'm not a fan of inline POD because it makes the code messy. Thus, I should be able to extract documentation from all the commenting. I'd only want a little markup in the comments, thus KwikiText is a perfect solution. Let's make a few simple rules.
# = NAME # HB::HandlerThing - handle things for HB # = METHODS ... # === modify_entity( $object, $data, $metainfo ) # Updates the Class::DBI $object from the given data structure, $data. # $metainfo is the appropriate information from HB->classinfo. # sub modify_entity { my ($self, $obj, $data, $meta) = @_; # $data should look like the following: # $data = { 'entities' => # 'entity' => { # '1' => { # property1 => .. # ...
# Ensure we have [=$data->{entities}{entity}]. my $entities = $data->{ $meta->{singular} } or return BAD_REQUEST, "Couldn't find entity(s) '$meta->{singular}' in content";
# Commit changes atomically my @rval = eval { my $given = $entities->{$obj->id};
# by first turning off automatic updating $obj->autoupdate(0);
# and then, foreach property, apply the change. foreach my $property ( keys %$given ) { my @errors = $self->_update_property( $obj, $property, $given->{$property}, $meta ); return @errors if @errors; }
...
= NAME HB::HandlerThing - handle things for HB = METHODS === modify_entity( $object, $data, $metainfo ) Updates the Class::DBI $object from the given data structure, $data. $metainfo is the appropriate information from HB->classinfo. $data should look like the following: $data = { 'entities' => 'entity' => { '1' => { property1 => .. ... Ensure we have [=$data->{entities}{entity}]. Commit changes atomically by first turning off automatic updating and then, foreach property, apply the change.
NAME
HB::HandlerThing - handle things for HB
METHODS
modify_entity( $object, $data, $metainfo )Updates the Class::DBI $object from the given data structure, $data. $metainfo is the appropriate information from HB->classinfo. $data should look like the following:$data = { 'entities' => 'entity' => { '1' => { property1 => .. ...Ensure we have $data->{entities}{entity}. Commit changes atomically by first turning off automatic updatingand then, foreach property, apply the change.