acts_as_api 0.3.11 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -4
- data/.travis.yml +5 -1
- data/Gemfile +2 -1
- data/History.txt +4 -0
- data/README.md +9 -4
- data/Rakefile +28 -5
- data/acts_as_api.gemspec +1 -1
- data/lib/acts_as_api/api_template.rb +54 -63
- data/lib/acts_as_api/array.rb +2 -2
- data/lib/acts_as_api/base.rb +19 -13
- data/lib/acts_as_api/config.rb +2 -2
- data/lib/acts_as_api/rendering.rb +4 -4
- data/lib/acts_as_api/version.rb +1 -1
- data/spec/README.md +55 -0
- data/spec/active_record_dummy/.gitignore +15 -0
- data/spec/active_record_dummy/Gemfile +16 -0
- data/spec/active_record_dummy/README.rdoc +261 -0
- data/spec/active_record_dummy/Rakefile +7 -0
- data/spec/{rails_app/public → active_record_dummy/app/assets}/images/rails.png +0 -0
- data/spec/active_record_dummy/app/assets/javascripts/application.js +15 -0
- data/spec/active_record_dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/active_record_dummy/app/controllers/application_controller.rb +3 -0
- data/spec/{rails_app → active_record_dummy}/app/helpers/application_helper.rb +0 -0
- data/spec/{rails_app/lib/tasks → active_record_dummy/app/mailers}/.gitkeep +0 -0
- data/spec/{rails_app/public/stylesheets → active_record_dummy/app/models}/.gitkeep +0 -0
- data/spec/{rails_app → active_record_dummy}/app/models/profile.rb +1 -0
- data/spec/active_record_dummy/app/models/task.rb +4 -0
- data/spec/{rails_app → active_record_dummy}/app/models/untouched.rb +0 -0
- data/spec/{rails_app → active_record_dummy}/app/models/user.rb +1 -0
- data/spec/active_record_dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/active_record_dummy/config.ru +4 -0
- data/spec/active_record_dummy/config/application.rb +59 -0
- data/spec/{rails_app → active_record_dummy}/config/boot.rb +0 -0
- data/spec/{rails_app → active_record_dummy}/config/database.yml +5 -3
- data/spec/active_record_dummy/config/environment.rb +5 -0
- data/spec/active_record_dummy/config/environments/development.rb +37 -0
- data/spec/active_record_dummy/config/environments/production.rb +67 -0
- data/spec/active_record_dummy/config/environments/test.rb +37 -0
- data/spec/{rails_app → active_record_dummy}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/active_record_dummy/config/initializers/generators.rb +2 -0
- data/spec/{rails_app → active_record_dummy}/config/initializers/inflections.rb +5 -0
- data/spec/{rails_app → active_record_dummy}/config/initializers/mime_types.rb +0 -0
- data/spec/active_record_dummy/config/initializers/secret_token.rb +7 -0
- data/spec/active_record_dummy/config/initializers/session_store.rb +8 -0
- data/spec/active_record_dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/{rails_app → active_record_dummy}/config/locales/en.yml +1 -1
- data/spec/active_record_dummy/config/routes.rb +59 -0
- data/spec/{rails_app → active_record_dummy}/db/migrate/20110214201640_create_tables.rb +0 -0
- data/spec/{rails_app → active_record_dummy}/db/schema.rb +0 -0
- data/spec/{rails_app → active_record_dummy}/db/seeds.rb +0 -0
- data/spec/active_record_dummy/doc/README_FOR_APP +2 -0
- data/spec/{rails_app/public/favicon.ico → active_record_dummy/lib/assets/.gitkeep} +0 -0
- data/spec/active_record_dummy/lib/tasks/.gitkeep +0 -0
- data/spec/active_record_dummy/log/.gitkeep +0 -0
- data/spec/{rails_app → active_record_dummy}/public/404.html +0 -0
- data/spec/{rails_app → active_record_dummy}/public/422.html +0 -0
- data/spec/{rails_app → active_record_dummy}/public/500.html +0 -1
- data/spec/active_record_dummy/public/favicon.ico +0 -0
- data/spec/{rails_app → active_record_dummy}/public/index.html +10 -8
- data/spec/{rails_app → active_record_dummy}/public/robots.txt +0 -0
- data/spec/{rails_app → active_record_dummy}/script/rails +0 -0
- data/spec/active_record_dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/active_record_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/active_record_dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/controllers/respond_with_users_controller_spec.rb +18 -33
- data/spec/controllers/users_controller_spec.rb +8 -25
- data/spec/models/{active_record_spec.rb → model_spec.rb} +5 -3
- data/spec/mongoid_dummy/.gitignore +15 -0
- data/spec/mongoid_dummy/Gemfile +18 -0
- data/spec/mongoid_dummy/README.rdoc +261 -0
- data/spec/mongoid_dummy/Rakefile +7 -0
- data/spec/mongoid_dummy/app/assets/images/rails.png +0 -0
- data/spec/mongoid_dummy/app/assets/javascripts/application.js +15 -0
- data/spec/mongoid_dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/mongoid_dummy/app/controllers/application_controller.rb +3 -0
- data/spec/mongoid_dummy/app/helpers/application_helper.rb +2 -0
- data/spec/mongoid_dummy/app/mailers/.gitkeep +0 -0
- data/spec/mongoid_dummy/app/models/.gitkeep +0 -0
- data/spec/{rails_app/app/models/mongo_profile.rb → mongoid_dummy/app/models/profile.rb} +2 -2
- data/spec/{rails_app/app/models/mongo_task.rb → mongoid_dummy/app/models/task.rb} +2 -2
- data/spec/{rails_app/app/models/mongo_untouched.rb → mongoid_dummy/app/models/untouched.rb} +1 -1
- data/spec/mongoid_dummy/app/models/user.rb +48 -0
- data/spec/mongoid_dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/mongoid_dummy/config.ru +4 -0
- data/spec/mongoid_dummy/config/application.rb +65 -0
- data/spec/mongoid_dummy/config/boot.rb +6 -0
- data/spec/mongoid_dummy/config/environment.rb +5 -0
- data/spec/{rails_app → mongoid_dummy}/config/environments/development.rb +10 -4
- data/spec/{rails_app → mongoid_dummy}/config/environments/production.rb +29 -14
- data/spec/{rails_app → mongoid_dummy}/config/environments/test.rb +8 -8
- data/spec/mongoid_dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/mongoid_dummy/config/initializers/generators.rb +2 -0
- data/spec/mongoid_dummy/config/initializers/include_acts_as_api.rb +3 -0
- data/spec/mongoid_dummy/config/initializers/inflections.rb +15 -0
- data/spec/mongoid_dummy/config/initializers/mime_types.rb +5 -0
- data/spec/mongoid_dummy/config/initializers/secret_token.rb +7 -0
- data/spec/mongoid_dummy/config/initializers/session_store.rb +8 -0
- data/spec/mongoid_dummy/config/initializers/wrap_parameters.rb +10 -0
- data/spec/mongoid_dummy/config/locales/en.yml +5 -0
- data/spec/{rails_app → mongoid_dummy}/config/mongoid.yml +8 -3
- data/spec/mongoid_dummy/config/routes.rb +59 -0
- data/spec/mongoid_dummy/db/seeds.rb +7 -0
- data/spec/mongoid_dummy/doc/README_FOR_APP +2 -0
- data/spec/mongoid_dummy/lib/assets/.gitkeep +0 -0
- data/spec/mongoid_dummy/lib/tasks/.gitkeep +0 -0
- data/spec/mongoid_dummy/log/.gitkeep +0 -0
- data/spec/mongoid_dummy/public/404.html +26 -0
- data/spec/mongoid_dummy/public/422.html +26 -0
- data/spec/mongoid_dummy/public/500.html +25 -0
- data/spec/mongoid_dummy/public/favicon.ico +0 -0
- data/spec/mongoid_dummy/public/index.html +241 -0
- data/spec/mongoid_dummy/public/robots.txt +5 -0
- data/spec/mongoid_dummy/script/rails +6 -0
- data/spec/mongoid_dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/mongoid_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/mongoid_dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/shared_engine/.gitignore +7 -0
- data/spec/shared_engine/Gemfile +14 -0
- data/spec/shared_engine/MIT-LICENSE +20 -0
- data/spec/shared_engine/README.rdoc +3 -0
- data/spec/shared_engine/Rakefile +29 -0
- data/spec/shared_engine/app/assets/images/shared_engine/.gitkeep +0 -0
- data/spec/shared_engine/app/assets/javascripts/shared_engine/application.js +15 -0
- data/spec/shared_engine/app/assets/stylesheets/shared_engine/application.css +13 -0
- data/spec/shared_engine/app/controllers/shared_engine/application_controller.rb +4 -0
- data/spec/shared_engine/app/controllers/shared_engine/respond_with_users_controller.rb +59 -0
- data/spec/shared_engine/app/controllers/shared_engine/users_controller.rb +71 -0
- data/spec/shared_engine/app/helpers/shared_engine/application_helper.rb +4 -0
- data/spec/shared_engine/app/models/user_template.rb +154 -0
- data/spec/shared_engine/app/views/layouts/shared_engine/application.html.erb +14 -0
- data/spec/{rails_app → shared_engine}/config/routes.rb +2 -4
- data/spec/shared_engine/dummy/README.rdoc +261 -0
- data/spec/{rails_app → shared_engine/dummy}/Rakefile +2 -2
- data/spec/shared_engine/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/shared_engine/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/shared_engine/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/shared_engine/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/shared_engine/dummy/app/mailers/.gitkeep +0 -0
- data/spec/shared_engine/dummy/app/models/.gitkeep +0 -0
- data/spec/shared_engine/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/{rails_app → shared_engine/dummy}/config.ru +1 -1
- data/spec/{rails_app → shared_engine/dummy}/config/application.rb +30 -10
- data/spec/shared_engine/dummy/config/boot.rb +10 -0
- data/spec/shared_engine/dummy/config/database.yml +25 -0
- data/spec/{rails_app → shared_engine/dummy}/config/environment.rb +1 -1
- data/spec/shared_engine/dummy/config/environments/development.rb +37 -0
- data/spec/shared_engine/dummy/config/environments/production.rb +67 -0
- data/spec/shared_engine/dummy/config/environments/test.rb +37 -0
- data/spec/shared_engine/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/shared_engine/dummy/config/initializers/inflections.rb +15 -0
- data/spec/shared_engine/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/{rails_app → shared_engine/dummy}/config/initializers/secret_token.rb +1 -1
- data/spec/{rails_app → shared_engine/dummy}/config/initializers/session_store.rb +2 -2
- data/spec/shared_engine/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/shared_engine/dummy/config/locales/en.yml +5 -0
- data/spec/shared_engine/dummy/config/routes.rb +4 -0
- data/spec/shared_engine/dummy/lib/assets/.gitkeep +0 -0
- data/spec/shared_engine/dummy/log/.gitkeep +0 -0
- data/spec/shared_engine/dummy/public/404.html +26 -0
- data/spec/shared_engine/dummy/public/422.html +26 -0
- data/spec/shared_engine/dummy/public/500.html +25 -0
- data/spec/shared_engine/dummy/public/favicon.ico +0 -0
- data/spec/shared_engine/dummy/script/rails +6 -0
- data/spec/shared_engine/lib/shared_engine.rb +4 -0
- data/spec/shared_engine/lib/shared_engine/engine.rb +5 -0
- data/spec/shared_engine/lib/shared_engine/version.rb +3 -0
- data/spec/shared_engine/lib/tasks/shared_engine_tasks.rake +4 -0
- data/spec/shared_engine/script/rails +8 -0
- data/spec/shared_engine/shared_engine.gemspec +22 -0
- data/spec/spec_helper.rb +16 -11
- data/spec/support/controller_examples.rb +35 -41
- data/spec/support/model_examples/associations.rb +13 -13
- data/spec/support/model_examples/enabled.rb +2 -2
- data/spec/support/model_examples/extending.rb +6 -6
- data/spec/support/model_examples/options.rb +53 -0
- data/spec/support/model_examples/untouched.rb +2 -2
- data/spec/support/simple_fixtures.rb +31 -59
- metadata +324 -132
- data/spec/models/mongoid_spec.rb +0 -29
- data/spec/models/vanilla_ruby_spec.rb +0 -31
- data/spec/rails_app/.gitignore +0 -4
- data/spec/rails_app/app/controllers/application_controller.rb +0 -11
- data/spec/rails_app/app/controllers/respond_with_users_controller.rb +0 -57
- data/spec/rails_app/app/controllers/users_controller.rb +0 -69
- data/spec/rails_app/app/models/mongo_user.rb +0 -192
- data/spec/rails_app/app/models/task.rb +0 -3
- data/spec/rails_app/app/models/vanilla_profile.rb +0 -16
- data/spec/rails_app/app/models/vanilla_task.rb +0 -16
- data/spec/rails_app/app/models/vanilla_untouched.rb +0 -2
- data/spec/rails_app/app/models/vanilla_user.rb +0 -195
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails_app/config/initializers/acts_as_api_mongoid.rb +0 -6
- data/spec/rails_app/public/javascripts/application.js +0 -2
- data/spec/rails_app/public/javascripts/controls.js +0 -965
- data/spec/rails_app/public/javascripts/dragdrop.js +0 -974
- data/spec/rails_app/public/javascripts/effects.js +0 -1123
- data/spec/rails_app/public/javascripts/prototype.js +0 -6001
- data/spec/rails_app/public/javascripts/rails.js +0 -191
data/spec/models/mongoid_spec.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Mongoid", :orm => "mongoid" do
|
|
4
|
-
|
|
5
|
-
before(:each) do
|
|
6
|
-
setup_mongoid_models
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
after(:each) do
|
|
10
|
-
clean_up_mongoid_models
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe :act_as_api do
|
|
14
|
-
it_supports "including an association in the api template"
|
|
15
|
-
it_supports "calling a closure in the api template"
|
|
16
|
-
it_supports "conditional if statements"
|
|
17
|
-
it_supports "conditional unless statements"
|
|
18
|
-
it_supports "acts_as_api is enabled"
|
|
19
|
-
it_supports "extending a given api template"
|
|
20
|
-
it_supports "calling a method in the api template"
|
|
21
|
-
it_supports "renaming"
|
|
22
|
-
it_supports "listing attributes in the api template"
|
|
23
|
-
it_supports "creating a sub hash in the api template"
|
|
24
|
-
it_supports "trying to render an api template that is not defined"
|
|
25
|
-
it_supports "untouched models"
|
|
26
|
-
it_supports "defining a model callback"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Class, :orm => "vanilla" do
|
|
4
|
-
|
|
5
|
-
before(:each) do
|
|
6
|
-
setup_roflscale_models
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
after(:each) do
|
|
10
|
-
clean_up_roflscale_models
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe :act_as_api do
|
|
14
|
-
# deactivated as I won't implement a fake association model just for specs ;)
|
|
15
|
-
# it_supports "including an association in the api template"
|
|
16
|
-
it_supports "calling a closure in the api template"
|
|
17
|
-
it_supports "conditional if statements"
|
|
18
|
-
it_supports "conditional unless statements"
|
|
19
|
-
it_supports "acts_as_api is enabled"
|
|
20
|
-
it_supports "extending a given api template"
|
|
21
|
-
it_supports "calling a method in the api template"
|
|
22
|
-
it_supports "renaming"
|
|
23
|
-
it_supports "listing attributes in the api template"
|
|
24
|
-
it_supports "creating a sub hash in the api template"
|
|
25
|
-
it_supports "trying to render an api template that is not defined"
|
|
26
|
-
# deactivated as acts_as_api won't get mixed into any class
|
|
27
|
-
# it_supports "untouched models"
|
|
28
|
-
it_supports "defining a model callback"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
data/spec/rails_app/.gitignore
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
class RespondWithUsersController < ApplicationController
|
|
2
|
-
|
|
3
|
-
respond_to :json, :xml
|
|
4
|
-
|
|
5
|
-
self.responder = ActsAsApi::Responder
|
|
6
|
-
|
|
7
|
-
def index
|
|
8
|
-
@users = @user_model.all
|
|
9
|
-
respond_with @users, :api_template => params[:api_template].to_sym, :root => :users
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def index_meta
|
|
13
|
-
@users = @user_model.all
|
|
14
|
-
meta_hash = { :page => 1, :total => 999 }
|
|
15
|
-
respond_with @users, :api_template => params[:api_template].to_sym, :root => :users, :meta => meta_hash
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def index_relation
|
|
19
|
-
@users = @user_model.limit(100)
|
|
20
|
-
respond_with @users, :api_template => params[:api_template].to_sym
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def show
|
|
24
|
-
@user = @user_model.find(params[:id])
|
|
25
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
26
|
-
respond_with @user, :api_template => params[:api_template].to_sym, :root => :user
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def show_meta
|
|
30
|
-
@user = @user_model.find(params[:id])
|
|
31
|
-
meta_hash = { :page => 1, :total => 999 }
|
|
32
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
33
|
-
respond_with @user, :api_template => params[:api_template].to_sym, :root => :user, :meta => meta_hash
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def show_default
|
|
37
|
-
@user = @user_model.find(params[:id])
|
|
38
|
-
respond_with @user
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def show_prefix_postfix
|
|
42
|
-
@user = @user_model.find(params[:id])
|
|
43
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
44
|
-
respond_with @user, :api_template => {:template => params[:api_template], :prefix => params[:api_prefix], :postfix => params[:api_postfix]}, :root => :user
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def create
|
|
48
|
-
@user = @user_model.new(params[:user])
|
|
49
|
-
|
|
50
|
-
if @user.save
|
|
51
|
-
respond_with @user, :api_template => params[:api_template]
|
|
52
|
-
else
|
|
53
|
-
respond_with @user
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
end
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
class UsersController < ApplicationController
|
|
2
|
-
|
|
3
|
-
def index
|
|
4
|
-
@users = @user_model.all
|
|
5
|
-
|
|
6
|
-
respond_to do |format|
|
|
7
|
-
format.xml { render_for_api params[:api_template].to_sym, :xml => @users, :root => :users }
|
|
8
|
-
format.json { render_for_api params[:api_template].to_sym, :json => @users, :root => :users }
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def index_meta
|
|
13
|
-
@users = @user_model.all
|
|
14
|
-
meta_hash = { :page => 1, :total => 999 }
|
|
15
|
-
|
|
16
|
-
respond_to do |format|
|
|
17
|
-
format.xml { render_for_api params[:api_template].to_sym, :xml => @users, :root => :users, :meta => meta_hash }
|
|
18
|
-
format.json { render_for_api params[:api_template].to_sym, :json => @users, :root => :users, :meta => meta_hash }
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def index_relation
|
|
23
|
-
@users = @user_model.limit(100)
|
|
24
|
-
|
|
25
|
-
respond_to do |format|
|
|
26
|
-
format.xml { render_for_api params[:api_template].to_sym, :xml => @users }
|
|
27
|
-
format.json { render_for_api params[:api_template].to_sym, :json => @users }
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def show
|
|
32
|
-
@user = @user_model.find(params[:id])
|
|
33
|
-
|
|
34
|
-
respond_to do |format|
|
|
35
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
36
|
-
format.xml { render_for_api params[:api_template].to_sym, :xml => @user, :root => :user }
|
|
37
|
-
format.json { render_for_api params[:api_template].to_sym, :json => @user, :root => :user }
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def show_meta
|
|
42
|
-
@user = @user_model.find(params[:id])
|
|
43
|
-
meta_hash = { :page => 1, :total => 999 }
|
|
44
|
-
respond_to do |format|
|
|
45
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
46
|
-
format.xml { render_for_api params[:api_template].to_sym, :xml => @user, :root => :user }
|
|
47
|
-
format.json { render_for_api params[:api_template].to_sym, :json => @user, :root => :user, :meta => meta_hash }
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def show_default
|
|
52
|
-
@user = @user_model.find(params[:id])
|
|
53
|
-
respond_to do |format|
|
|
54
|
-
format.xml { render :xml => @user }
|
|
55
|
-
format.json { render :json => @user }
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def show_prefix_postfix
|
|
60
|
-
@user = @user_model.find(params[:id])
|
|
61
|
-
template = {:template => params[:api_template], :prefix => params[:api_prefix], :postfix => params[:api_postfix]}
|
|
62
|
-
respond_to do |format|
|
|
63
|
-
# :root => :user is only used here because we need it for the node name of the MongoUser model
|
|
64
|
-
format.xml { render_for_api template, :xml => @user, :root => :user }
|
|
65
|
-
format.json { render_for_api template, :json => @user, :root => :user }
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
class MongoUser
|
|
2
|
-
|
|
3
|
-
include Mongoid::Document
|
|
4
|
-
|
|
5
|
-
field :first_name, :type => String
|
|
6
|
-
field :last_name, :type => String
|
|
7
|
-
field :age, :type => Integer
|
|
8
|
-
field :active, :type => Boolean
|
|
9
|
-
field :created_at, :type => DateTime
|
|
10
|
-
field :updated_at, :type => DateTime
|
|
11
|
-
|
|
12
|
-
embeds_one :profile, :class_name => "MongoProfile", :inverse_of => :user
|
|
13
|
-
embeds_many :tasks, :class_name => "MongoTask", :inverse_of => :user
|
|
14
|
-
|
|
15
|
-
acts_as_api
|
|
16
|
-
|
|
17
|
-
api_accessible :name_only do |t|
|
|
18
|
-
t.add :first_name
|
|
19
|
-
t.add :last_name
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
api_accessible :only_full_name do |t|
|
|
23
|
-
t.add :full_name
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
api_accessible :rename_last_name do |t|
|
|
27
|
-
t.add :last_name, :as => :family_name
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
api_accessible :rename_full_name do |t|
|
|
31
|
-
t.add :full_name, :as => :other_full_name
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
api_accessible :with_former_value do |t|
|
|
35
|
-
t.add :first_name
|
|
36
|
-
t.add :last_name
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
api_accessible :age_and_first_name, :extend => :with_former_value do |t|
|
|
40
|
-
t.add :age
|
|
41
|
-
t.remove :last_name
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
api_accessible :calling_a_proc do |t|
|
|
45
|
-
t.add Proc.new{|model| model.full_name.upcase }, :as => :all_caps_name
|
|
46
|
-
t.add Proc.new{|model| Time.now.class.to_s }, :as => :without_param
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
api_accessible :calling_a_lambda do |t|
|
|
50
|
-
t.add lambda{|model| model.full_name.upcase }, :as => :all_caps_name
|
|
51
|
-
t.add lambda{|model| Time.now.class.to_s }, :as => :without_param
|
|
52
|
-
end
|
|
53
|
-
api_accessible :include_tasks do |t|
|
|
54
|
-
t.add :tasks
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
api_accessible :include_profile do |t|
|
|
58
|
-
t.add :profile
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
api_accessible :other_sub_template do |t|
|
|
62
|
-
t.add :first_name
|
|
63
|
-
t.add :tasks, :template => :other_template
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
api_accessible :include_completed_tasks do |t|
|
|
67
|
-
t.add "tasks.completed.all", :as => :completed_tasks
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
api_accessible :sub_node do |t|
|
|
71
|
-
t.add Hash[:foo => :say_something], :as => :sub_nodes
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
api_accessible :nested_sub_node do |t|
|
|
75
|
-
t.add Hash[:foo, Hash[:bar, :last_name]], :as => :sub_nodes
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
api_accessible :nested_sub_hash do |t|
|
|
79
|
-
t.add :sub_hash
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
api_accessible :if_over_thirty do |t|
|
|
83
|
-
t.add :first_name
|
|
84
|
-
t.add :last_name, :if => :over_thirty?
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
api_accessible :if_returns_nil do |t|
|
|
88
|
-
t.add :first_name
|
|
89
|
-
t.add :last_name, :if => :return_nil
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
api_accessible :if_over_thirty_proc do |t|
|
|
93
|
-
t.add :first_name
|
|
94
|
-
t.add :last_name, :if => lambda{|u| u.over_thirty? }
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
api_accessible :if_returns_nil_proc do |t|
|
|
98
|
-
t.add :first_name
|
|
99
|
-
t.add :last_name, :if => lambda{|u| nil }
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
api_accessible :unless_under_thirty do |t|
|
|
103
|
-
t.add :first_name
|
|
104
|
-
t.add :last_name, :unless => :under_thirty?
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
api_accessible :unless_returns_nil do |t|
|
|
108
|
-
t.add :first_name
|
|
109
|
-
t.add :last_name, :unless => :return_nil
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
api_accessible :unless_under_thirty_proc do |t|
|
|
113
|
-
t.add :first_name
|
|
114
|
-
t.add :last_name, :unless => lambda{|u| u.under_thirty? }
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
api_accessible :unless_returns_nil_proc do |t|
|
|
118
|
-
t.add :first_name
|
|
119
|
-
t.add :last_name, :unless => lambda{|u| nil }
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
api_accessible :with_prefix_name_only do |t|
|
|
123
|
-
t.add lambda{|model| 'true' }, :as => :prefix
|
|
124
|
-
t.add :first_name
|
|
125
|
-
t.add :last_name
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
api_accessible :name_only_with_postfix do |t|
|
|
129
|
-
t.add :first_name
|
|
130
|
-
t.add :last_name
|
|
131
|
-
t.add lambda{|model| 'true' }, :as => :postfix
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
api_accessible :with_prefix_name_only_with_postfix do |t|
|
|
135
|
-
t.add lambda{|model| 'true' }, :as => :prefix
|
|
136
|
-
t.add :first_name
|
|
137
|
-
t.add :last_name
|
|
138
|
-
t.add lambda{|model| 'true' }, :as => :postfix
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def before_api_response(api_response)
|
|
142
|
-
@before_api_response_called = true
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def before_api_response_called?
|
|
146
|
-
!!@before_api_response_called
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def after_api_response(api_response)
|
|
150
|
-
@after_api_response_called = true
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def after_api_response_called?
|
|
154
|
-
!!@after_api_response_called
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def skip_api_response=(should_skip)
|
|
158
|
-
@skip_api_response = should_skip
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def around_api_response(api_response)
|
|
162
|
-
@skip_api_response ? { :skipped => true } : yield
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def over_thirty?
|
|
166
|
-
age > 30
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
def under_thirty?
|
|
170
|
-
age < 30
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def return_nil
|
|
174
|
-
nil
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def full_name
|
|
178
|
-
'' << first_name.to_s << ' ' << last_name.to_s
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def say_something
|
|
182
|
-
"something"
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def sub_hash
|
|
186
|
-
{
|
|
187
|
-
:foo => "bar",
|
|
188
|
-
:hello => "world"
|
|
189
|
-
}
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class VanillaProfile
|
|
2
|
-
extend ActsAsApi::Base
|
|
3
|
-
|
|
4
|
-
attr_accessor :user, :avatar, :homepage, :created_at, :updated_at
|
|
5
|
-
|
|
6
|
-
def initialize(opts)
|
|
7
|
-
opts.each do |k,v|
|
|
8
|
-
self.send :"#{k}=", v
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def model_name
|
|
13
|
-
'profile'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class VanillaTask
|
|
2
|
-
extend ActsAsApi::Base
|
|
3
|
-
|
|
4
|
-
attr_accessor :user, :heading, :description, :time_spent, :done, :created_at, :updated_at
|
|
5
|
-
|
|
6
|
-
def initialize(opts)
|
|
7
|
-
opts.each do |k,v|
|
|
8
|
-
self.send :"#{k}=", v
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def model_name
|
|
13
|
-
'task'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|