[Jifty-commit] jifty branch, jifty_client, updated. 71b72da4108bfb851682dce70edcc5a00850bcfa
Jifty commits
jifty-commit at lists.jifty.org
Sat May 1 03:50:10 EDT 2010
The branch, jifty_client has been updated
via 71b72da4108bfb851682dce70edcc5a00850bcfa (commit)
from a64dac54ccac9e8eb711a623aabe3c8748442463 (commit)
Summary of changes:
lib/Jifty/Plugin/REST/Dispatcher.pm | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 71b72da4108bfb851682dce70edcc5a00850bcfa
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Sat May 1 15:50:04 2010 +0800
Serialize a bunch of Jifty column names into the Joose class
diff --git a/lib/Jifty/Plugin/REST/Dispatcher.pm b/lib/Jifty/Plugin/REST/Dispatcher.pm
index 3da801c..e3231c3 100644
--- a/lib/Jifty/Plugin/REST/Dispatcher.pm
+++ b/lib/Jifty/Plugin/REST/Dispatcher.pm
@@ -952,7 +952,40 @@ sub show_joose_class {
my ($model) = model(shift);
Jifty::Util->require($model) or abort(404);
(my $class_name = $model) =~ s/.*:://;
- return "Class('$class_name');";
+
+ my $cols = {};
+ for my $col ( $model->new->columns ) {
+ next if $col->private or $col->virtual;
+ my $props = {};
+
+ # map Jifty column property names to Joose names
+ if ($col->default) {
+ $props->{init} = Scalar::Defer::force($col->default);
+ }
+
+ if ($col->mandatory) {
+ $props->{required} = 1;
+ }
+
+ if ($col->readable) {
+ if ($col->writable) {
+ $props->{is} = 'rw';
+ }
+ else {
+ $props->{is} = 'ro';
+ }
+ }
+
+ $cols->{$col->name} = $props;
+ }
+
+ my $properties = {
+ has => $cols,
+ };
+
+ return "Class('$class_name',"
+ . Jifty::JSON::encode_json($properties)
+ . ");";
}
=head2 run_action
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list