the_garage 2.4.4 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/app/assets/config/manifest.js +2 -0
- data/lib/garage/config.rb +5 -3
- data/lib/garage/representer.rb +1 -1
- data/lib/garage/resource_casting_responder.rb +1 -1
- data/lib/garage/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8b827892d32f5517d67991bfc76a4832eba4f3aa5b1c1d1cd1f76141bc3422
|
4
|
+
data.tar.gz: fce58bbb7be2ef82e68416650419d88e3bf10205c011806660081a594cf29d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d691e438110eabee1b14a9f011067f67f4cf5119f248843d6c4d8d3f44125e7f7a76f0b56d12cac53770238425c6a2d5f62c4321e8273264ce4306e6f943c0e8
|
7
|
+
data.tar.gz: d408e49c73f46d1fcda1d3d8f9a61a76b8a7e6411172bf4eace5c38c4572be838e4c0f65e1f8dea5006949532b741fc19de4600d72fccde4a49dc8bc7468f810
|
data/README.md
CHANGED
@@ -52,7 +52,7 @@ In your controller classes:
|
|
52
52
|
```ruby
|
53
53
|
class ApplicationController < ActionController::Base
|
54
54
|
include Garage::ControllerHelper
|
55
|
-
|
55
|
+
|
56
56
|
# ...
|
57
57
|
end
|
58
58
|
|
@@ -65,6 +65,18 @@ class EmployeesController < ApplicationController
|
|
65
65
|
end
|
66
66
|
```
|
67
67
|
|
68
|
+
Resources are rendered with [respond_with (responders gem)](https://github.com/heartcombo/responders).
|
69
|
+
Additional options can be passed to respond_with by implementing `respond_with_resources_options` (index action)
|
70
|
+
and `respond_with_resource_options` (show, update destroy actions).
|
71
|
+
|
72
|
+
Available options
|
73
|
+
* `:paginate` - (Boolean) Enable pagination when `true`. Paginates with the `per_page` and `page` params
|
74
|
+
* `:per_page` - (Integer) value for default number of resources per page when paginating
|
75
|
+
* `:max_per_page` - (Integer) Maximum resources per page, irrespective of requested per_page
|
76
|
+
* `:hard_limit` - (Integer) Limit of retrievable records when paginating. Also hides total records.
|
77
|
+
* `:distinct_by` - (Symbol) Specify a property to count by for total page count
|
78
|
+
* `:to_resource_options` - (Hash) Options to pass as argument to `to_resource(options)`
|
79
|
+
|
68
80
|
## Create decorator for your AR models
|
69
81
|
With not small application, you may add a presentation layer to build API responses.
|
70
82
|
Define a decorator class with `Resource` suffix and define `#to_resource` in
|
data/lib/garage/config.rb
CHANGED
@@ -49,11 +49,13 @@ module Garage
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def cast_resource
|
52
|
-
@cast_resource ||= proc { |resource|
|
52
|
+
@cast_resource ||= proc { |resource, options|
|
53
|
+
options ||= {}
|
54
|
+
to_resource_args = [options[:to_resource_options]].compact
|
53
55
|
if resource.respond_to?(:map) && resource.respond_to?(:to_a)
|
54
|
-
resource.map(
|
56
|
+
resource.map { |r| r.to_resource(*to_resource_args) }
|
55
57
|
else
|
56
|
-
resource.to_resource
|
58
|
+
resource.to_resource(*to_resource_args)
|
57
59
|
end
|
58
60
|
}
|
59
61
|
end
|
data/lib/garage/representer.rb
CHANGED
data/lib/garage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_garage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuhiko Miyagawa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- MIT-LICENSE
|
189
189
|
- README.md
|
190
190
|
- Rakefile
|
191
|
+
- app/assets/config/manifest.js
|
191
192
|
- app/assets/javascripts/garage/application.js
|
192
193
|
- app/assets/javascripts/garage/docs/console.js.coffee
|
193
194
|
- app/assets/javascripts/garage/docs/jquery.colorbox.js
|
@@ -255,7 +256,7 @@ homepage: https://github.com/cookpad/garage
|
|
255
256
|
licenses:
|
256
257
|
- MIT
|
257
258
|
metadata: {}
|
258
|
-
post_install_message:
|
259
|
+
post_install_message:
|
259
260
|
rdoc_options: []
|
260
261
|
require_paths:
|
261
262
|
- lib
|
@@ -270,8 +271,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
271
|
- !ruby/object:Gem::Version
|
271
272
|
version: '0'
|
272
273
|
requirements: []
|
273
|
-
rubygems_version: 3.
|
274
|
-
signing_key:
|
274
|
+
rubygems_version: 3.1.2
|
275
|
+
signing_key:
|
275
276
|
specification_version: 4
|
276
277
|
summary: Garage Platform Engine
|
277
278
|
test_files: []
|