jb 0.4.0 → 0.4.1
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 +17 -11
- data/lib/jb/action_view_monkeys.rb +2 -0
- data/lib/jb/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: 2cecf7538261118f837e0e2495f9c8d2cf2871be
|
4
|
+
data.tar.gz: 9fcbbbb4b2c4dcf38a4d64702252227e1d6c251b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc797c8330ab9ab0316eaf460fa25cd847f817e54bfe8823f0cf2241ec021e9026177c8eb8667a9f75e3e31650811ad065a3de1c9a4f8a088a769224e24df987
|
7
|
+
data.tar.gz: 7a8740e87eede6bd2009437465fc2f81bb94844a678fe98e3d0c9f4520940490ba717d8e01d30e0cf7e659c50424248dad4fa7922cdafdf8ef96e2da6ddb1d16
|
data/README.md
CHANGED
@@ -52,14 +52,18 @@ if current_user.admin?
|
|
52
52
|
json[:visitors] = calculate_visitors(@message)
|
53
53
|
end
|
54
54
|
|
55
|
-
json[:comments] =
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
json[:comments] = @message.comments.map do |comment|
|
56
|
+
{
|
57
|
+
content: comment.content,
|
58
|
+
created_at: comment.created_at
|
59
|
+
}
|
60
|
+
end
|
59
61
|
|
60
62
|
json[:attachments] = @message.attachments.map do |attachment|
|
61
|
-
|
62
|
-
|
63
|
+
{
|
64
|
+
filename: attachment.filename,
|
65
|
+
url: url_for(attachment)
|
66
|
+
}
|
63
67
|
end
|
64
68
|
|
65
69
|
json
|
@@ -110,10 +114,12 @@ And you know, Ruby is such a powerful language for manipulating collections:
|
|
110
114
|
# @comments = @post.comments
|
111
115
|
|
112
116
|
@comments.reject {|c| c.marked_as_spam_by?(current_user) }.map do |comment|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
+
{
|
118
|
+
body: comment.body,
|
119
|
+
author: {
|
120
|
+
first_name: comment.author.first_name,
|
121
|
+
last_name: comment.author.last_name
|
122
|
+
}
|
117
123
|
}
|
118
124
|
end
|
119
125
|
|
@@ -222,7 +228,7 @@ and then it [falls back to the `view_context`'s `render` method](https://github.
|
|
222
228
|
|
223
229
|
So, for example if the collection has 100 elements, Jbuilder's `render partial:` performs `render` method 100 times, and so it calls `find_template` method (which is known as one of the heaviest parts of Action View) 100 times.
|
224
230
|
|
225
|
-
OTOH, Jb simply calls [ActionView::PartialRenderer's `render`](https://github.com/rails/rails/blob/49a881e0db1ef64fcbae2b7ddccfd5ccea26ae01/actionview/lib/action_view/renderer/partial_renderer.rb#L423-L443) which is cleverly
|
231
|
+
OTOH, Jb simply calls [ActionView::PartialRenderer's `render`](https://github.com/rails/rails/blob/49a881e0db1ef64fcbae2b7ddccfd5ccea26ae01/actionview/lib/action_view/renderer/partial_renderer.rb#L423-L443) which is cleverly implemented to `find_template` only once beforehand, then pass each element to that template.
|
226
232
|
|
227
233
|
|
228
234
|
## Benchmarks
|
data/lib/jb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|