jb 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99330e1b9a45c061cc3d3f5e25c458df7ff83ccc
4
- data.tar.gz: b0cb88236cf475aa2bfc223e495911d56b5a6bfa
3
+ metadata.gz: 2cecf7538261118f837e0e2495f9c8d2cf2871be
4
+ data.tar.gz: 9fcbbbb4b2c4dcf38a4d64702252227e1d6c251b
5
5
  SHA512:
6
- metadata.gz: 0d919a4c75278e24704ef2c927a3dab80f980496baaac7974cd3ff5643a1f9d00428800549caf9c72e1096b0bf7a486f81fe0bd5c73c180ef6e40b4627662aa1
7
- data.tar.gz: c92b98d29d4f91f6e3e59ecf6130728082b5d2caab4f6cccbbb9f38a4da2c6f7329098488733e05f6429d4a690fe4284a9be3650a2868966757e3355d1c7d1be
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
- content: @message.comments.content,
57
- created_at: @message.comments.created_at
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
- filename: attachment.filename,
62
- url: url_for(attachment)
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
- body: comment.body,
114
- author: {
115
- first_name: comment.author.first_name,
116
- last_name: comment.author.last_name
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 implmented to `find_template` only once beforehand, then pass each element to that template.
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
@@ -1,3 +1,5 @@
1
+ require 'multi_json'
2
+
1
3
  module Jb
2
4
  module PartialRenderer
3
5
  module JbTemplateDetector
@@ -1,3 +1,3 @@
1
1
  module Jb
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
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.0
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-07-15 00:00:00.000000000 Z
11
+ date: 2016-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json