active_model_exporters 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +2 -14
- data/lib/action_controller/exportation.rb +5 -3
- data/lib/active_model/exporter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0378a96ebc63c714524b298cbf7b33c431e3ee7f
|
4
|
+
data.tar.gz: a6d3e85fa50c76ff0d949548eeee2a20496daa70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a35fa0e950ee7253fe7f040b9909753a7802814d578229cbcd3e67ccea6d15975f93aa5bb8bdd3bfff2d603bbde8052251869334744c61a1295df7518c113fb5
|
7
|
+
data.tar.gz: 19ead28f4367fb080f350ab031d3245b9580f32235fe8b6ca7bf1ce64ee718de7cfba4254b617640bc975e48fe5359fe5ac124b521f9c9ed1036e5e174cff866
|
data/README.md
CHANGED
@@ -37,18 +37,6 @@ class PostsController < ApplicationController
|
|
37
37
|
end
|
38
38
|
```
|
39
39
|
|
40
|
-
Or:
|
41
|
-
```ruby
|
42
|
-
class PostsController < ApplicationController
|
43
|
-
respond_to :csv, :xls
|
44
|
-
|
45
|
-
def index
|
46
|
-
@posts = Post.all
|
47
|
-
respond_with @posts
|
48
|
-
end
|
49
|
-
end
|
50
|
-
```
|
51
|
-
|
52
40
|
### Custom exporter
|
53
41
|
To specify a custom exporter for each object, you can do the next in your controller:
|
54
42
|
```ruby
|
@@ -83,7 +71,7 @@ end
|
|
83
71
|
### Exporter scope
|
84
72
|
|
85
73
|
#### 1. Default scope
|
86
|
-
As `ActiveModel::Serializers` does, you can access to the current user
|
74
|
+
As `ActiveModel::Serializers` does, you can access to the current user via `scope`.
|
87
75
|
```ruby
|
88
76
|
class UserExporter < ActiveModel::Exporter
|
89
77
|
attributes :name, :email
|
@@ -137,4 +125,4 @@ Rejected attributes will be blank in the downloaded file.
|
|
137
125
|
|
138
126
|
New feature or code refactoring? Submit a pull request that implements it. Don't forget to write your tests and include a CHANGELOG with your updates.
|
139
127
|
|
140
|
-
Thank you
|
128
|
+
Thank you!
|
@@ -14,9 +14,11 @@ module ActionController
|
|
14
14
|
end
|
15
15
|
|
16
16
|
ActiveModel::Exporter::TYPES.each do |type|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
[:_render_option_, :_render_with_renderer_json].each do |prefix|
|
18
|
+
define_method "#{prefix}#{type}" do |resource, options|
|
19
|
+
exporter = build_exporter(resource, options)
|
20
|
+
exporter ? super(exporter, options) : super
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model_exporters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Gutiérrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|