diff options
| author | mo k <mo.khan@gmail.com> | 2014-11-21 17:13:56 -0700 |
|---|---|---|
| committer | mo k <mo.khan@gmail.com> | 2014-11-21 17:13:56 -0700 |
| commit | ac9f4566d79fabdaeff6eed935c524eee222fede (patch) | |
| tree | 42906f55065af137b0cc68e299c5086fcc69bfdd /app/controllers/api | |
| parent | 1aa0d01e08e8bf841411da8b5bf29298d6f387b8 (diff) | |
| parent | 19070364fb882140c37e3a782e5eb5e210ce7f8b (diff) | |
Merged in mocheen/cakeside/ember-api (pull request #118)
create v2 of api to match ember rest adapter.
Diffstat (limited to 'app/controllers/api')
| -rw-r--r-- | app/controllers/api/v2/cakes_controller.rb | 18 | ||||
| -rw-r--r-- | app/controllers/api/v2/categories_controller.rb | 9 | ||||
| -rw-r--r-- | app/controllers/api/v2/photos_controller.rb | 13 | ||||
| -rw-r--r-- | app/controllers/api/v2/users_controller.rb | 13 |
4 files changed, 53 insertions, 0 deletions
diff --git a/app/controllers/api/v2/cakes_controller.rb b/app/controllers/api/v2/cakes_controller.rb new file mode 100644 index 00000000..48e17b87 --- /dev/null +++ b/app/controllers/api/v2/cakes_controller.rb @@ -0,0 +1,18 @@ +module Api + module V2 + class CakesController < ApplicationController + def initialize(repository = Spank::IOC.resolve(:cakes)) + @repository = repository + super() + end + + def index + @cakes = @repository.search_with(params).page(page).per(per_page) + end + + def show(id = params[:id]) + @cake = @repository.find(id) + end + end + end +end diff --git a/app/controllers/api/v2/categories_controller.rb b/app/controllers/api/v2/categories_controller.rb new file mode 100644 index 00000000..365544b6 --- /dev/null +++ b/app/controllers/api/v2/categories_controller.rb @@ -0,0 +1,9 @@ +module Api + module V2 + class CategoriesController < ApplicationController + def show + @category = @categories.find(params[:id]) + end + end + end +end diff --git a/app/controllers/api/v2/photos_controller.rb b/app/controllers/api/v2/photos_controller.rb new file mode 100644 index 00000000..c4240327 --- /dev/null +++ b/app/controllers/api/v2/photos_controller.rb @@ -0,0 +1,13 @@ +module Api + module V2 + class PhotosController < ApplicationController + def index + @photos = Photo.page(page).per(per_page) + end + + def show(id = params[:id]) + @photo = Photo.find(id) + end + end + end +end diff --git a/app/controllers/api/v2/users_controller.rb b/app/controllers/api/v2/users_controller.rb new file mode 100644 index 00000000..471069bb --- /dev/null +++ b/app/controllers/api/v2/users_controller.rb @@ -0,0 +1,13 @@ +module Api + module V2 + class UsersController < ApplicationController + def index + @users = User.page(page).per(per_page) + end + + def show(id = params[:id]) + @user = User.find(id) + end + end + end +end |
