[Jifty-commit] r2159 - in jifty/trunk/lib/Jifty: . Event Plugin/REST

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Nov 15 02:00:51 EST 2006


Author: jesse
Date: Wed Nov 15 02:00:50 2006
New Revision: 2159

Modified:
   jifty/trunk/lib/Jifty/Event/Model.pm
   jifty/trunk/lib/Jifty/Param/Schema.pm
   jifty/trunk/lib/Jifty/Plugin/REST/Dispatcher.pm
   jifty/trunk/lib/Jifty/Subs.pm

Log:
 * Supply documentation for all tof the methods which had been missing it

Modified: jifty/trunk/lib/Jifty/Event/Model.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Event/Model.pm	(original)
+++ jifty/trunk/lib/Jifty/Event/Model.pm	Wed Nov 15 02:00:50 2006
@@ -6,6 +6,31 @@
 use base qw/Jifty::Event/;
 
 
+
+=head1 NAME
+
+Jifty::Event::Model
+
+=head1 DESCRIPTION
+
+Objects in this class represent changes to Jifty::Record classes (any action on a model class)
+as Jifty::Events.
+
+As yet, this functionality is unused.
+
+
+=cut
+
+=head2 new
+
+creates a new L<Jifty::Event::Model> object.  If C<PubSub> is enabled for your application, 
+checks to make sure that this event has the following (underdocumented) parameters:
+
+ record_id record_class action_class action_arguments timestamp result as_hash_before as_hash_after current_user_id
+
+=cut
+
+
 sub new {
     my $class = shift;
     my $self = $class->SUPER::new(@_);

Modified: jifty/trunk/lib/Jifty/Param/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Param/Schema.pm	(original)
+++ jifty/trunk/lib/Jifty/Param/Schema.pm	Wed Nov 15 02:00:50 2006
@@ -149,6 +149,14 @@
             HASH   => sub { Hash::Merge::_merge_hashes( $_[0], $_[1] ) } }
 };
 
+=head2 merge_params HASHREF HASHREF
+
+Takes two hashrefs. Merges them together and returns the merged hashref.
+
+BUG: This should either be a private routine or factored out into Jifty::Util
+
+=cut
+
 sub merge_params {
     my $prev_behaviour = Hash::Merge::get_behavior();
     Hash::Merge::specify_behavior( MERGE_PARAM_BEHAVIOUR, "merge_params" );

Modified: jifty/trunk/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/REST/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/REST/Dispatcher.pm	Wed Nov 15 02:00:50 2006
@@ -5,6 +5,7 @@
 
 
 use CGI qw( start_html end_html ol ul li a dl dt dd );
+use Carp;
 use Jifty::Dispatcher -base;
 use Jifty::YAML ();
 use Jifty::JSON ();
@@ -34,11 +35,30 @@
 on GET    '/=/action'      => \&list_actions;
 on POST   '/=/action/*'    => \&run_action;
 
+
+=head2 list PREFIX items
+
+Takes a URL prefix and a set of items to render. passes them on.
+
+=cut
+
+
+
 sub list {
     my $prefix = shift;
     outs($prefix, \@_)
 }
 
+
+
+=head2 outs PREFIX DATASTRUCTURE
+
+TAkes a url path prefix and a datastructure.  Depending on what content types the other side of the HTTP connection can accept,
+renders the content as yaml, json, javascript, perl, xml or html.
+
+=cut
+
+
 sub outs {
     my $prefix = shift;
     my $accept = ($ENV{HTTP_ACCEPT} || '');
@@ -90,6 +110,12 @@
 our $xml_config = { SuppressEmpty => '',
                     NoAttr => 1 };
 
+=head2 render_as_xml DATASTRUCTURE
+
+Attempts to render DATASTRUCTURE as simple, tag-based XML.
+
+=cut
+
 sub render_as_xml {
     my $content = shift;
 
@@ -104,6 +130,12 @@
 }
 
 
+=head2 render_as_html PREFIX URL DATASTRUCTURE
+
+Attempts to render DATASTRUCTURE as simple semantic HTML suitable for humans to look at.
+
+=cut
+
 sub render_as_html {
     my $prefix = shift;
     my $url = shift;
@@ -135,6 +167,12 @@
 }
 
 
+=head2 html_dump DATASTRUCTURE
+
+Recursively render DATASTRUCTURE as some simple html dls and ols. 
+
+=cut
+
 
 sub html_dump {
     my $content = shift;
@@ -159,6 +197,12 @@
     }
 }
 
+=head2 html_dump_record Jifty::Record
+
+Returns a nice simple HTML definition list of the keys and values of a Jifty::Record object.
+
+=cut
+
 
 sub html_dump_record {
     my $item = shift;
@@ -167,10 +211,24 @@
      return  dl( map {dt($_), dd($hash{$_}) } keys %hash )
 }
 
-sub action { resolve($_[0], 'Jifty::Action', Jifty->api->actions) }
-sub model  { resolve($_[0], 'Jifty::Record', Jifty->class_loader->models) }
+=head2 action ACTION
+
+Canonicalizes ACTION into the form preferred by the code. (Cleans up casing, canonicalizing, etc. Returns 404 if it can't work its magic
+
+=cut
 
-sub resolve {
+
+sub action {  _resolve($_[0], 'Jifty::Action', Jifty->api->actions) }
+
+=head2 model MODEL
+
+Canonicalizes MODEL into the form preferred by the code. (Cleans up casing, canonicalizing, etc. Returns 404 if it can't work its magic
+
+=cut
+
+sub model  { _resolve($_[0], 'Jifty::Record', Jifty->class_loader->models) }
+
+sub _resolve {
     my $name = shift;
     my $base = shift;
     return $name if $name->isa($base);
@@ -184,6 +242,13 @@
     abort(404);
 }
 
+
+=head2 list_models
+
+Sends the user a list of models in this application, with the names transformed from Perlish::Syntax to Everything.Else.Syntax
+
+=cut
+
 sub list_models {
     list(['model'], map {s/::/./g; $_ } Jifty->class_loader->models);
 }
@@ -208,6 +273,14 @@
     valid_values
 );
 
+
+=head2 list_model_columns
+
+Sends the user a nice list of all columns in a given model class. Exactly which model is shoved into $1 by the dispatcher. This should probably be improved.
+
+
+=cut
+
 sub list_model_columns {
     my ($model) = model($1);
 
@@ -222,6 +295,13 @@
     );
 }
 
+=head2 list_model_items MODELCLASS COLUMNNAME
+
+Returns a list of items in MODELCLASS sorted by COLUMNNAME, with only COLUMNAME displayed.  (This should have some limiting thrown in)
+
+=cut
+
+
 sub list_model_items {
 
     # Normalize model name - fun!
@@ -235,6 +315,16 @@
         map { $_->$column() } @{ $col->items_array_ref || [] } );
 }
 
+
+=head2 show_item_field $model, $column, $key, $field
+
+Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns the value of C<$field> for that object. 
+Returns 404 if it doesn't exist.
+
+
+
+=cut
+
 sub show_item_field {
     my ( $model, $column, $key, $field ) = ( model($1), $2, $3, $4 );
     my $rec = $model->new;
@@ -244,6 +334,14 @@
     outs( [ 'model', $model, $column, $key, $field ], $rec->$field());
 }
 
+=head2 show_item $model, $column, $key
+
+Loads up a model of type C<$model> which has a column C<$column> with a value C<$key>. Returns  all columns for the object
+
+Returns 404 if it doesn't exist.
+
+=cut
+
 sub show_item {
     my ($model, $column, $key) = (model($1), $2, $3);
     my $rec = $model->new;
@@ -252,18 +350,45 @@
     outs( ['model', $model, $column, $key],  { map {$_ => $rec->$_()} map {$_->name} $rec->columns});
 }
 
+
+=head2 replace_item
+
+UNIMPLEMENTED
+
+=cut
+
 sub replace_item {
     die "hey replace item";
 }
 
+=head2 delete_item
+
+UNIMPLEMENTED
+
+=cut
+
 sub delete_item {
     die "hey delete item";
 }
 
+=head2 list_actions
+
+Returns a list of all actions allowed to the current user. (Canonicalizes Perl::Style to Everything.Else.Style).
+
+=cut
+
 sub list_actions {
     list(['action'], map {s/::/./g; $_} Jifty->api->actions);
 }
 
+=head2 list_action_params
+
+Takes a single parameter, $action, supplied by the dispatcher.
+
+Shows the user all possible parameters to the action, currently in the form of a form to run that action.
+
+=cut
+
 sub list_action_params {
     my ($action) = action($1) or abort(404);
     Jifty::Util->require($action) or abort(404);

Modified: jifty/trunk/lib/Jifty/Subs.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Subs.pm	(original)
+++ jifty/trunk/lib/Jifty/Subs.pm	Wed Nov 15 02:00:50 2006
@@ -29,6 +29,38 @@
 
 =cut
 
+=head2 add PARAMHASH
+
+Add a subscription for the current window or session.
+
+Takes the following parameters
+
+=over
+
+=item class
+
+What class of object shall we subscribe to notifications on
+
+=item queries
+
+An array of queries to match items of class C<class> against. The implementation of C<queries> is dependent on the type of object events are being recorded against
+
+=item mode
+
+How should the fragment sent to the client on matching events be rendered. Valid modes are C<Replace>, C<Bottom> and C<Top>
+
+=item region
+
+The moniker of the region that updates to this subscription should be rendered into
+
+=item render_with
+
+The path of the fragment used to render items matching this subscription
+
+=back
+
+=cut
+
 sub add {
     my $class = shift;
     my $args = {@_};
@@ -79,6 +111,12 @@
     return "$channel!$id";
 }
 
+=head2 cancel CHANNEL_ID
+
+Cancels session or window's subscription to CHANNEL_ID
+
+=cut
+
 sub cancel {
     my ($class, $channel_id) = @_;
 
@@ -111,6 +149,13 @@
     );
 }
 
+=head2 list [window/sessionid]
+
+Returns a lost of channel ids this session or window is subscribed to.
+
+=cut
+
+
 sub list {
     my $self = shift;
 


More information about the Jifty-commit mailing list