mongosteen 0.1.3 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +3 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +204 -0
- data/README.md +32 -55
- data/Rakefile +16 -2
- data/lib/mongosteen.rb +24 -13
- data/lib/mongosteen/actions.rb +6 -0
- data/lib/mongosteen/base_helpers.rb +6 -7
- data/lib/mongosteen/class_methods.rb +6 -2
- data/lib/mongosteen/permitted_params.rb +3 -34
- data/lib/mongosteen/version.rb +1 -1
- data/mongosteen.gemspec +13 -4
- data/test/.DS_Store +0 -0
- data/test/controllers/.keep +0 -0
- data/test/helpers/.keep +0 -0
- data/test/integration/api_test.rb +95 -0
- data/test/rails_app/.DS_Store +0 -0
- data/test/rails_app/Rakefile +6 -0
- data/test/rails_app/app/assets/images/.keep +0 -0
- data/test/rails_app/app/assets/javascripts/application.js +16 -0
- data/test/rails_app/app/assets/stylesheets/application.css +15 -0
- data/test/rails_app/app/controllers/application_controller.rb +5 -0
- data/test/rails_app/app/controllers/concerns/.keep +0 -0
- data/test/rails_app/app/controllers/test_items_controller.rb +5 -0
- data/test/rails_app/app/controllers/test_permit_items_controller.rb +9 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/mailers/.keep +0 -0
- data/test/rails_app/app/models/concerns/.keep +0 -0
- data/test/rails_app/app/models/test_item.rb +16 -0
- data/test/rails_app/app/models/test_permit_item.rb +7 -0
- data/test/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +8 -0
- data/test/rails_app/bin/rake +8 -0
- data/test/rails_app/bin/setup +29 -0
- data/test/rails_app/bin/spring +15 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +32 -0
- data/test/rails_app/config/boot.rb +3 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +38 -0
- data/test/rails_app/config/environments/production.rb +76 -0
- data/test/rails_app/config/environments/test.rb +42 -0
- data/test/rails_app/config/initializers/assets.rb +11 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app/config/initializers/inflections.rb +16 -0
- data/test/rails_app/config/initializers/mime_types.rb +4 -0
- data/test/rails_app/config/initializers/session_store.rb +3 -0
- data/test/rails_app/config/initializers/wrap_parameters.rb +9 -0
- data/test/rails_app/config/locales/en.yml +23 -0
- data/test/rails_app/config/mongoid.yml +9 -0
- data/test/rails_app/config/routes.rb +6 -0
- data/test/rails_app/config/secrets.yml +22 -0
- data/test/rails_app/db/seeds.rb +7 -0
- data/test/rails_app/lib/assets/.keep +0 -0
- data/test/rails_app/lib/tasks/.keep +0 -0
- data/test/rails_app/public/404.html +67 -0
- data/test/rails_app/public/422.html +67 -0
- data/test/rails_app/public/500.html +66 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/public/robots.txt +5 -0
- data/test/rails_app/vendor/assets/javascripts/.keep +0 -0
- data/test/rails_app/vendor/assets/stylesheets/.keep +0 -0
- data/test/test_helper.rb +16 -0
- metadata +158 -22
- data/CONTRIBUTING.md +0 -24
- data/lib/mongoid/fake_criteria.rb +0 -24
- data/lib/mongoid/serializable_id.rb +0 -19
- data/lib/mongoid/sorted_relations.rb +0 -61
- data/lib/mongosteen/engine.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2ffeeae51d0306d1f73592a7625c8d7aedd5845
|
4
|
+
data.tar.gz: 01698c266ab659745f276d5f3d0c1b0e76fb3abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0bc8e85b29307e7da8c3525199e8e37165036b5d0eefb95fc50d521c4c1fe7e4a4dfc1fa55f21b3d9e3d454926f9bdc3842fcbd235b61a06108fce73a74636b
|
7
|
+
data.tar.gz: 75a9eeaf8caad1b54d849e2524466ff85fd8b693fc1235d0eb11af89a8b6b7e326d46a061e8b4a554ce739e13a057c77d0597c77ee07518222a1dd734214d279
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mongosteen (0.1.6)
|
5
|
+
has_scope (> 0.5)
|
6
|
+
inherited_resources (>= 1.6)
|
7
|
+
kaminari (>= 0.16)
|
8
|
+
mongoid (>= 4.0)
|
9
|
+
mongoid-history (>= 0.4.5)
|
10
|
+
mongoid_search (>= 0.3)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: http://rubygems.org/
|
14
|
+
specs:
|
15
|
+
actionmailer (4.2.0)
|
16
|
+
actionpack (= 4.2.0)
|
17
|
+
actionview (= 4.2.0)
|
18
|
+
activejob (= 4.2.0)
|
19
|
+
mail (~> 2.5, >= 2.5.4)
|
20
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
21
|
+
actionpack (4.2.0)
|
22
|
+
actionview (= 4.2.0)
|
23
|
+
activesupport (= 4.2.0)
|
24
|
+
rack (~> 1.6.0)
|
25
|
+
rack-test (~> 0.6.2)
|
26
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
28
|
+
actionview (4.2.0)
|
29
|
+
activesupport (= 4.2.0)
|
30
|
+
builder (~> 3.1)
|
31
|
+
erubis (~> 2.7.0)
|
32
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
34
|
+
activejob (4.2.0)
|
35
|
+
activesupport (= 4.2.0)
|
36
|
+
globalid (>= 0.3.0)
|
37
|
+
activemodel (4.2.0)
|
38
|
+
activesupport (= 4.2.0)
|
39
|
+
builder (~> 3.1)
|
40
|
+
activerecord (4.2.0)
|
41
|
+
activemodel (= 4.2.0)
|
42
|
+
activesupport (= 4.2.0)
|
43
|
+
arel (~> 6.0)
|
44
|
+
activesupport (4.2.0)
|
45
|
+
i18n (~> 0.7)
|
46
|
+
json (~> 1.7, >= 1.7.7)
|
47
|
+
minitest (~> 5.1)
|
48
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
49
|
+
tzinfo (~> 1.1)
|
50
|
+
ansi (1.5.0)
|
51
|
+
arel (6.0.0)
|
52
|
+
bson (2.3.0)
|
53
|
+
builder (3.2.2)
|
54
|
+
capybara (2.4.4)
|
55
|
+
mime-types (>= 1.16)
|
56
|
+
nokogiri (>= 1.3.3)
|
57
|
+
rack (>= 1.0.0)
|
58
|
+
rack-test (>= 0.5.4)
|
59
|
+
xpath (~> 2.0)
|
60
|
+
capybara-webkit (1.4.1)
|
61
|
+
capybara (>= 2.3.0, < 2.5.0)
|
62
|
+
json
|
63
|
+
coffee-rails (4.1.0)
|
64
|
+
coffee-script (>= 2.2.0)
|
65
|
+
railties (>= 4.0.0, < 5.0)
|
66
|
+
coffee-script (2.4.1)
|
67
|
+
coffee-script-source
|
68
|
+
execjs
|
69
|
+
coffee-script-source (1.9.1.1)
|
70
|
+
connection_pool (2.2.0)
|
71
|
+
database_cleaner (1.4.1)
|
72
|
+
easy_diff (0.0.4)
|
73
|
+
erubis (2.7.0)
|
74
|
+
execjs (2.5.2)
|
75
|
+
factory_girl (4.5.0)
|
76
|
+
activesupport (>= 3.0.0)
|
77
|
+
factory_girl_rails (4.5.0)
|
78
|
+
factory_girl (~> 4.5.0)
|
79
|
+
railties (>= 3.0.0)
|
80
|
+
fast-stemmer (1.0.2)
|
81
|
+
globalid (0.3.5)
|
82
|
+
activesupport (>= 4.1.0)
|
83
|
+
has_scope (0.6.0)
|
84
|
+
actionpack (>= 3.2, < 5)
|
85
|
+
activesupport (>= 3.2, < 5)
|
86
|
+
i18n (0.7.0)
|
87
|
+
inherited_resources (1.6.0)
|
88
|
+
actionpack (>= 3.2, < 5)
|
89
|
+
has_scope (~> 0.6.0.rc)
|
90
|
+
railties (>= 3.2, < 5)
|
91
|
+
responders
|
92
|
+
json (1.8.3)
|
93
|
+
kaminari (0.16.3)
|
94
|
+
actionpack (>= 3.0.0)
|
95
|
+
activesupport (>= 3.0.0)
|
96
|
+
loofah (2.0.2)
|
97
|
+
nokogiri (>= 1.5.9)
|
98
|
+
mail (2.6.3)
|
99
|
+
mime-types (>= 1.16, < 3)
|
100
|
+
mime-types (2.6.1)
|
101
|
+
mini_portile (0.6.2)
|
102
|
+
minitest (5.7.0)
|
103
|
+
minitest-capybara (0.7.1)
|
104
|
+
capybara (~> 2.2)
|
105
|
+
minitest (~> 5.0)
|
106
|
+
rake
|
107
|
+
minitest-focus (1.1.1)
|
108
|
+
minitest (>= 4, < 6)
|
109
|
+
minitest-metadata (0.5.3)
|
110
|
+
minitest (>= 4.7, < 6.0)
|
111
|
+
minitest-rails (2.2.0)
|
112
|
+
minitest (~> 5.7)
|
113
|
+
railties (~> 4.1)
|
114
|
+
minitest-rails-capybara (2.1.1)
|
115
|
+
capybara (~> 2.0)
|
116
|
+
minitest-capybara (~> 0.7.0)
|
117
|
+
minitest-metadata (~> 0.5.0)
|
118
|
+
minitest-rails (~> 2.1)
|
119
|
+
minitest-reporters (1.0.16)
|
120
|
+
ansi
|
121
|
+
builder
|
122
|
+
minitest (>= 5.0)
|
123
|
+
ruby-progressbar
|
124
|
+
mongoid (4.0.2)
|
125
|
+
activemodel (~> 4.0)
|
126
|
+
moped (~> 2.0.0)
|
127
|
+
origin (~> 2.1)
|
128
|
+
tzinfo (>= 0.3.37)
|
129
|
+
mongoid-history (0.4.7)
|
130
|
+
activesupport
|
131
|
+
easy_diff
|
132
|
+
mongoid (>= 3.0)
|
133
|
+
mongoid_search (0.3.2)
|
134
|
+
fast-stemmer (~> 1.0.0)
|
135
|
+
mongoid (>= 3.0.0)
|
136
|
+
moped (2.0.4)
|
137
|
+
bson (~> 2.2)
|
138
|
+
connection_pool (~> 2.0)
|
139
|
+
optionable (~> 0.2.0)
|
140
|
+
nokogiri (1.6.6.2)
|
141
|
+
mini_portile (~> 0.6.0)
|
142
|
+
optionable (0.2.0)
|
143
|
+
origin (2.1.1)
|
144
|
+
rack (1.6.1)
|
145
|
+
rack-test (0.6.3)
|
146
|
+
rack (>= 1.0)
|
147
|
+
rails (4.2.0)
|
148
|
+
actionmailer (= 4.2.0)
|
149
|
+
actionpack (= 4.2.0)
|
150
|
+
actionview (= 4.2.0)
|
151
|
+
activejob (= 4.2.0)
|
152
|
+
activemodel (= 4.2.0)
|
153
|
+
activerecord (= 4.2.0)
|
154
|
+
activesupport (= 4.2.0)
|
155
|
+
bundler (>= 1.3.0, < 2.0)
|
156
|
+
railties (= 4.2.0)
|
157
|
+
sprockets-rails
|
158
|
+
rails-deprecated_sanitizer (1.0.3)
|
159
|
+
activesupport (>= 4.2.0.alpha)
|
160
|
+
rails-dom-testing (1.0.6)
|
161
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
162
|
+
nokogiri (~> 1.6.0)
|
163
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
164
|
+
rails-html-sanitizer (1.0.2)
|
165
|
+
loofah (~> 2.0)
|
166
|
+
railties (4.2.0)
|
167
|
+
actionpack (= 4.2.0)
|
168
|
+
activesupport (= 4.2.0)
|
169
|
+
rake (>= 0.8.7)
|
170
|
+
thor (>= 0.18.1, < 2.0)
|
171
|
+
rake (10.4.2)
|
172
|
+
responders (2.1.0)
|
173
|
+
railties (>= 4.2.0, < 5)
|
174
|
+
ruby-progressbar (1.7.5)
|
175
|
+
sprockets (3.2.0)
|
176
|
+
rack (~> 1.0)
|
177
|
+
sprockets-rails (2.3.1)
|
178
|
+
actionpack (>= 3.0)
|
179
|
+
activesupport (>= 3.0)
|
180
|
+
sprockets (>= 2.8, < 4.0)
|
181
|
+
thor (0.19.1)
|
182
|
+
thread_safe (0.3.5)
|
183
|
+
tzinfo (1.2.2)
|
184
|
+
thread_safe (~> 0.1)
|
185
|
+
xpath (2.0.0)
|
186
|
+
nokogiri (~> 1.3)
|
187
|
+
|
188
|
+
PLATFORMS
|
189
|
+
ruby
|
190
|
+
|
191
|
+
DEPENDENCIES
|
192
|
+
capybara-webkit
|
193
|
+
coffee-rails (~> 4.1.0)
|
194
|
+
database_cleaner
|
195
|
+
factory_girl_rails
|
196
|
+
kaminari
|
197
|
+
minitest-focus
|
198
|
+
minitest-rails-capybara
|
199
|
+
minitest-reporters
|
200
|
+
mongoid
|
201
|
+
mongoid-history
|
202
|
+
mongosteen!
|
203
|
+
rails (= 4.2.0)
|
204
|
+
rake (>= 0.8.7)
|
data/README.md
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
# Mongosteen
|
4
4
|
|
5
|
-
## An easy way to add restful actions
|
6
5
|
|
7
|
-
|
6
|
+
## An easy way to add RESTful actions
|
7
|
+
|
8
|
+
Mongosteen is a library that helps to easily add RESTful actions to mongoid models, providing support for search, pagination, scopes, json configuration and history.
|
9
|
+
|
10
|
+
Mongosteen is based on [inherited_resources](https://github.com/josevalim/inherited_resources) gem, get yourself familiar with how it works and what you can do with this great tool.
|
8
11
|
|
9
|
-
Mongosteen is based on [inherited_resources](https://github.com/josevalim/inherited_resources) gem, get yourself familiar on how it works and setup using it's documentation.
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
@@ -30,9 +32,10 @@ Mongosteen is based on [inherited_resources](https://github.com/josevalim/inheri
|
|
30
32
|
resources :posts
|
31
33
|
```
|
32
34
|
|
35
|
+
|
33
36
|
## Mongosteen API
|
34
37
|
|
35
|
-
|
38
|
+
### Index
|
36
39
|
|
37
40
|
Index supports **search**, **page**, **perPage** and **scope** parameters:
|
38
41
|
|
@@ -45,7 +48,8 @@ Check out external gems documentation to see what options they provide:
|
|
45
48
|
- **[kaminari](https://github.com/amatsuda/kaminari)** — generic Rails pagination solution;
|
46
49
|
- **[has_scope](https://github.com/plataformatec/has_scope)** — easy way to access mongoid model scopes via controller;
|
47
50
|
|
48
|
-
|
51
|
+
|
52
|
+
### Versions
|
49
53
|
|
50
54
|
Get specific resource **version**:
|
51
55
|
|
@@ -57,9 +61,10 @@ No how to add history support for mongoid model, check out:
|
|
57
61
|
|
58
62
|
- **[mongoid-history](https://github.com/aq1018/mongoid-history)** — track changes to mongoid document;
|
59
63
|
|
60
|
-
#### JSON config for model
|
61
64
|
|
62
|
-
|
65
|
+
### JSON configuration for models
|
66
|
+
|
67
|
+
Sometimes there is a need to configure json output for the model, for example to add model method to output or exclude some internal fields. Mongosteen provides an easy and isolated way to do that in model controller using ```json_config``` method:
|
63
68
|
|
64
69
|
```ruby
|
65
70
|
class PostsController < ApplicationController
|
@@ -68,73 +73,45 @@ Some times there is a need to configure json output for the model, for example t
|
|
68
73
|
end
|
69
74
|
```
|
70
75
|
|
71
|
-
```json_config``` accepts configuration hash and passes it to [as_json](http://apidock.com/rails/ActiveResource/Base/as_json) method
|
72
|
-
|
73
|
-
#### Sorted Relations
|
76
|
+
```json_config``` accepts configuration hash and passes it to [as_json](http://apidock.com/rails/ActiveResource/Base/as_json) method while rendering document json.
|
74
77
|
|
75
|
-
In Mongoid, the HABTM relations return docs in the wrong order. This workaround gives your document the ability to retrieve it's relations in the same order it was placed in. This is refactored version of an original [mongoid-sorted-relations](https://github.com/demarque/mongoid-sorted-relations) gem.
|
76
78
|
|
77
|
-
|
79
|
+
### Permitted Parameters
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
class Post
|
83
|
-
include Mongoid::Document
|
84
|
-
include Mongoid::SortedRelations
|
85
|
-
|
86
|
-
has_and_belongs_to_many :authors
|
87
|
-
end
|
88
|
-
|
89
|
-
post = Book.new title: 'Restful actions with Mongosteen'
|
90
|
-
post.authors << Author.create name: "Alexander Kravets"
|
91
|
-
post.authors << Author.create name: "Roman Brazhnyk"
|
92
|
-
post.authors << Author.create name: "Maxim Melnyk"
|
93
|
-
|
94
|
-
post.sorted_authors.map(&:name)
|
95
|
-
#=> ['Alexander Kravets', 'Roman Brazhnyk', 'Maxim Melnyk']
|
96
|
-
```
|
97
|
-
|
98
|
-
Check out orignal gem [documentation](https://github.com/demarque/mongoid-sorted-relations) for more usage examples.
|
99
|
-
|
100
|
-
#### Permitted Parameters
|
101
|
-
|
102
|
-
For easiness of prototyping, Mongosteen has a workaround that allows all input parameters for ```create``` and ```update``` methods. This default behaviour can be overriden by using ```permitted_params``` method inside of models controller, e.g.:
|
81
|
+
For rapid prototyping, Mongosteen allows all input parameters for ```create``` and ```update``` methods. This default behaviour can be overriden by using ```permitted_params``` method in controller, e.g:
|
103
82
|
|
104
83
|
```ruby
|
105
84
|
class Admin::PostsController < Admin::BaseController
|
106
85
|
mongosteen
|
107
86
|
|
108
|
-
|
87
|
+
private
|
109
88
|
|
110
|
-
|
111
|
-
|
112
|
-
|
89
|
+
def post_params
|
90
|
+
params.require(:post).permit(:title, :body)
|
91
|
+
end
|
113
92
|
end
|
114
93
|
```
|
115
94
|
|
116
|
-
#### Serializable Model Id
|
117
95
|
|
118
|
-
|
96
|
+
## Mongosteen family
|
119
97
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
include Mongoid::SerializedId
|
125
|
-
end
|
126
|
-
```
|
98
|
+
- [Character](https://github.com/slate-studio/chr): Powerful responsive javascript CMS for apps
|
99
|
+
- [Mongosteen](https://github.com/slate-studio/mongosteen): An easy way to add RESTful actions for Mongoid models
|
100
|
+
- [Inverter](https://github.com/slate-studio/inverter): An easy way to connect Rails templates content to Character CMS
|
101
|
+
- [Loft](https://github.com/slate-studio/loft): Media assets manager for Character CMS
|
127
102
|
|
128
|
-
## The Mongosteen family
|
129
103
|
|
130
|
-
|
104
|
+
## License
|
105
|
+
|
106
|
+
Copyright © 2015 [Slate Studio, LLC](http://slatestudio.com). Mongoosteen is free software, and may be redistributed under the terms specified in the [license](LICENSE.md).
|
107
|
+
|
131
108
|
|
132
|
-
##
|
109
|
+
## About Slate Studio
|
133
110
|
|
134
111
|
[![Slate Studio](https://slate-git-images.s3-us-west-1.amazonaws.com/slate.png)](http://slatestudio.com)
|
135
112
|
|
136
|
-
|
113
|
+
Mongoosteen is maintained and funded by [Slate Studio, LLC](http://slatestudio.com). Tweet your questions or suggestions to [@slatestudio](https://twitter.com/slatestudio) and while you’re at it follow us too.
|
114
|
+
|
115
|
+
|
137
116
|
|
138
|
-
## License
|
139
117
|
|
140
|
-
Copyright © 2015 [Slate Studio, LLC](http://slatestudio.com). Mongosteen is free software, and may be redistributed under the terms specified in the [license](LICENSE.md).
|
data/Rakefile
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rdoc/task'
|
6
|
+
|
7
|
+
desc 'Default: run tests for all ORMs.'
|
8
|
+
task default: :test
|
9
|
+
|
10
|
+
desc 'Run Mongosteen unit tests.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
t.warning = false
|
17
|
+
end
|
data/lib/mongosteen.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
1
|
+
# @TODO: take a look at http://jsonapi.org/implementations/
|
2
|
+
|
4
3
|
|
5
4
|
require 'inherited_resources'
|
6
|
-
require '
|
5
|
+
require 'mongoid_search'
|
6
|
+
require 'mongoid-history'
|
7
7
|
require 'kaminari'
|
8
|
+
require 'has_scope'
|
9
|
+
|
8
10
|
|
9
11
|
module Mongosteen
|
10
12
|
autoload :Actions, 'mongosteen/actions'
|
@@ -13,36 +15,45 @@ module Mongosteen
|
|
13
15
|
autoload :PermittedParams, 'mongosteen/permitted_params'
|
14
16
|
|
15
17
|
class Engine < ::Rails::Engine
|
16
|
-
|
17
|
-
require 'mongoid/fake_criteria'
|
18
|
-
require 'mongoid/sorted_relations'
|
19
|
-
require 'mongoid/serializable_id'
|
18
|
+
# auto wire
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
22
|
+
|
23
23
|
class ActionController::Base
|
24
|
-
|
25
|
-
#
|
24
|
+
|
25
|
+
# Call mongosteen in your controller to have all the
|
26
|
+
# required modules and funcionality included.
|
26
27
|
def self.mongosteen
|
27
28
|
self.class_eval do
|
29
|
+
|
28
30
|
inherit_resources
|
29
31
|
|
30
32
|
respond_to :json
|
33
|
+
|
31
34
|
class_attribute :as_json_config
|
35
|
+
class_attribute :json_default_methods
|
32
36
|
|
33
37
|
extend Mongosteen::ClassMethods
|
34
38
|
include Mongosteen::BaseHelpers
|
35
39
|
include Mongosteen::Actions
|
36
40
|
include Mongosteen::PermittedParams
|
37
41
|
|
38
|
-
# configure permitted_params to accept all attributes
|
39
42
|
instance_name = self.resources_configuration[:self][:instance_name]
|
43
|
+
|
44
|
+
# configure permitted_params to accept all attributes
|
40
45
|
define_method("#{ instance_name }_params") { params_all_permitted }
|
41
46
|
private "#{ instance_name }_params"
|
47
|
+
|
48
|
+
# support for character default list item attributes
|
49
|
+
chr_default_methods = %w( _list_item_title _list_item_subtitle _list_item_thumbnail )
|
50
|
+
self.json_default_methods = chr_default_methods.select { |m| self.resource_class.method_defined? m }
|
51
|
+
|
52
|
+
json_config()
|
53
|
+
|
42
54
|
end
|
43
55
|
end
|
44
|
-
end
|
45
|
-
|
46
56
|
|
57
|
+
end
|
47
58
|
|
48
59
|
|