Render Collection/Members

5 views
Skip to first unread message

Helmut Juskewycz

unread,
Feb 28, 2011, 3:46:11 AM2/28/11
to restfulie
Hi all,

I am currently evaluating Restfulie as a Rest solution. And so far
Restfulie looks like a viable solution. However, I do have some
problem with tokamak and the builders. For me they seem awfully
complicated and confusing. Since there isn't much documentation on
tokamak, I hope you can help understand some of the basics.

1. collections, members, member, root, member.members

Without any disrespect, the naming is very confusing. In most examples
and tests the examples are:

collection do |member|
member.members ...
...

Can you please explain to me:

- collection vs members
- member
- when does a block get 1 or 2 param set, what is the value of that
param
- when to use what

2. Best Practices

Are there any?

3. How would you present the following hierarchy:

projects => lists all projects as links
projects/#id => lists all project (details) and 2 member collections
(e.g. tasks, collaborator) as links

Thank you, I appreciate any help.


Guilherme Silveira

unread,
Feb 28, 2011, 8:52:53 AM2/28/11
to rest...@googlegroups.com
Hello Helmut,

I am willing to change the dsl (in a backward compatible way). The
following dsl is supported in a branch:
https://github.com/abril/tokamak/pull/1

I can adapt it to this other one, which I believe is the most
straightforward one:
https://gist.github.com/847327

What do you think? In the least one, there is no extra variables or
methods such as collections/members/member. It is the common
ruby code with each's to iterate on collections.
Just gimme a green sign and I can finish this implementation so you can try it.

Using this dsl, the answer to (3) is:

1.
projects {
each(@projects) do |project|
link "self", url_for(project)
end
}

2.
project {
id @project.id
name @project.name

tasks {
each(@project.tasks) do |t|
link "self", url_for(t)
end
}

# just a variation to show you how to do it
link "collaborators", url_for([@project, @project.collaborators])

}

Regards


Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Helmut Juskewycz

unread,
Mar 1, 2011, 3:40:34 AM3/1/11
to restfulie
Hi Guilherme,

the dsl from https://gist.github.com/847327 is definitely the way to
go. Looks much cleaner and rubyish. If you need some help
(implementing or testing), just let me know.

On Feb 28, 2:52 pm, Guilherme Silveira
> Caelum | Ensino e Inovaçãohttp://www.caelum.com.br/

Guilherme Silveira

unread,
Mar 3, 2011, 7:46:58 PM3/3/11
to rest...@googlegroups.com, erich.egert
Hi Helmut,

Today me and Erich spent some time implementing it, we got half way
though it (xml!).

https://github.com/caelum/tokamak/tree/dsl

What is currently does:
- supports almost everything on xml, except the namespace (just add
support, should not be hard)

So its missing:
- support Json
- support namespace on xml

Can you help me supporting the namespace on xml or replicating the xml
tests with the new dsl on the json_spec and implementing it? I believe
its just a matter of changing the members method on the json file.

After that I can fix the hook.

Its fully backwards compatible and I also applied the other branches.

Let me know what you can do and we can do the rest here.

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Guilherme Silveira

unread,
Mar 31, 2011, 10:30:38 AM3/31/11
to rest...@googlegroups.com, hjusk...@gmail.com
Hi everyone, Helmut!

With the help from Paniz and Anderson we were able to finish the DSL.
https://github.com/caelum/tokamak/tree/dsl

Now its all about ruby enumerations + block invocations:

product {
link :self, product_url(prod)
id prod.id
name prod.name
price prod.price
}

Let me know if you like it!

Regards
Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Helmut Juskewycz

unread,
Apr 1, 2011, 6:10:37 AM4/1/11
to restfulie
Guilherme,

the new dsl looks great and much more concise. I wanted to integrate
Restfulie in a project of mine this weekend. I will do it with the new
dsl, so I can give you some more feedback on Monday.

Thanks again for the quick response and styling the tokamak dsl more
rubyish :)

On Mar 31, 4:30 pm, Guilherme Silveira
<guilherme.silve...@caelum.com.br> wrote:
> Hi everyone, Helmut!
>
> With the help from Paniz and Anderson we were able to finish the DSL.https://github.com/caelum/tokamak/tree/dsl
>
> Now its all about ruby enumerations + block invocations:
>
> product {
>   link   :self,  product_url(prod)
>   id prod.id
>   name prod.name
>   price prod.price
>
> }
>
> Let me know if you like it!
>
> Regards
> Guilherme Silveira
> Caelum | Ensino e Inovaçãohttp://www.caelum.com.br/
>
> On Thu, Mar 3, 2011 at 9:46 PM, Guilherme Silveira
>
>
>
>
>
>
>
> <guilherme.silve...@caelum.com.br> wrote:
> > Hi Helmut,
>
> > Today me and Erich spent some time implementing it, we got half way
> > though it (xml!).
>
> >https://github.com/caelum/tokamak/tree/dsl
>
> > What is currently does:
> > - supports almost everything on xml, except the namespace (just add
> > support, should not be hard)
>
> > So its missing:
> > - support Json
> > - support namespace on xml
>
> > Can you help me supporting the namespace on xml or replicating the xml
> > tests with the new dsl on the json_spec and implementing it? I believe
> > its just a matter of changing the members method on the json file.
>
> > After that I can fix the hook.
>
> > Its fully backwards compatible and I also applied the other branches.
>
> > Let me know what you can do and we can do the rest here.
>
> > Regards
>
> > Guilherme Silveira
> > Caelum | Ensino e Inovação
> >http://www.caelum.com.br/
>
> > On Tue, Mar 1, 2011 at 5:40 AM, Helmut Juskewycz <hjuskew...@gmail.com> wrote:
> >> Hi Guilherme,
>
> >> the dsl fromhttps://gist.github.com/847327is definitely the way to

Guilherme Silveira

unread,
Apr 1, 2011, 10:27:32 AM4/1/11
to rest...@googlegroups.com
Great!

Let me know if the dependencies work fine... you will have to grab it
from the branches. I will work onputting them on master during the
weekend too,should be easy.

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Reply all
Reply to author
Forward
0 new messages