From 51771906abe18f13ca11f4452181212ffc5f2223 Mon Sep 17 00:00:00 2001 From: Nathan Esquenazi Date: Wed, 23 Jan 2013 11:43:25 -0800 Subject: [PATCH] Adds SYNTAX.md to new branch for finishing #216 --- SYNTAX.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 SYNTAX.md diff --git a/SYNTAX.md b/SYNTAX.md new file mode 100644 index 00000000..2512d076 --- /dev/null +++ b/SYNTAX.md @@ -0,0 +1,93 @@ +# Syntax + +## Steps + + - [ ] Change documentation + - [ ] Update tests to reflect new syntax changes + - [ ] Add new tests for special cases (collection with nodes outside) + - [ ] Fix code to match + +## Summary + +Temporary file for storing the syntax changes: + +## Change object syntax into a block + +```ruby +object @post do |p| + attributes :id, :name, :body, :created_at +end +``` + +```ruby +object :article => @post do |p| + attributes :id, :name, :body, :created_at +end +``` + +## Change collection syntax into a block + +```ruby +collection :articles => @posts do |p| + attributes :id, :name, :body, :created_at + + node :is_read do |p| + p.read_by? @user + end + + child :author do |p| + attributes :name, :username, :email + end +end +``` + +## Change caching syntax + +Change caching syntax to reflect changes: + +```ruby +object @post do + cache @post + # or cache true + attributes :foo, :bar +end +``` + +## Handle collections with extra nodes + +```ruby +collection :articles => @posts do |p| + # ... +end + +node :total_pages do + @posts.total_pages +end + +node :current_page do + @posts.current_page +end +``` + +as well as if the collection has no root node with: + +``` +{ collection: [....], total_pages: xx } +``` + +## Reverse hash syntax from + +```ruby +collection @posts => :articles +``` + +to + +```ruby +collection :articles => @posts +``` + +## Improved handling of collection and object commands + +If the developer says 'object' then assume object, if they say collection then assume collection. +We no longer will detect this ourselves. \ No newline at end of file