joosy / joosy-rails

Joosy Rails ties
MIT License
1 stars 4 forks source link

Implement automatic resources generation #2

Closed inossidabile closed 11 years ago

inossidabile commented 11 years ago

Expected to fix https://github.com/joosy/joosy/issues/80

sandrew commented 11 years ago

given

resources :blogs do
  resources :posts do
    resources :comments
  end
end

namespace 'admin' do
  resources :blogs do
    resources :comments
  end
end

will generate following resources:

class Blog extends Joosy.Resource.REST
  @entity 'blog'

class Post extends Joosy.Resource.REST
  @entity 'post'

class Comment extends Joosy.Resource.REST
  @entity 'comment'

class Blog.Post extends Post
  @source '/blogs/:blog_id/posts'

class Blog.Post.Comment extends Comment
  @source '/blogs/:blog_id/posts/:post_id/comments'

class Admin.Blog extends Blog
  @source '/admin/blogs'

class Admin.Blog.Comment extends Comment
  @source '/admin/blogs/:blog_id/comments'
inossidabile commented 11 years ago

Like I mentioned at corresponding issue of core repo (https://github.com/joosy/joosy/issues/106) – the question here is how are we going to switch between variations of Blog resource. To make it real we have to add ability to override @source on the instance level and make @on to make exactly that. Right?

sandrew commented 11 years ago

yes, exactly. but with @at instead of @on :-)

inossidabile commented 11 years ago

yea lol. What a funny typo :)