jbuilder 2.2.11 → 2.2.12
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/CHANGELOG.md +5 -0
- data/jbuilder.gemspec +1 -1
- data/lib/jbuilder.rb +11 -11
- data/lib/jbuilder/jbuilder_template.rb +4 -4
- 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: e20ebff9d84c8c417da4626184d5c0360d96039c
|
4
|
+
data.tar.gz: 73e44d30685bdd6db5655c8cd3c6c6e5087f21e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4447541e8d14944f440ff55d1bdc88a2b64a14aadcf43de76aaa1ae308e430ceadb25e9bd60707963655ef407b9b27b5f6eaa298bc5b800e6392736cee3d3847
|
7
|
+
data.tar.gz: 87ec45135f3d1fb89f20cc51b51e9f62cf69b270af5ef55fe52e5706aac70da2799b4f5b71e584816e74a2727703a6471e3370e4589e81a79599727caa01db66
|
data/CHANGELOG.md
CHANGED
data/jbuilder.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'jbuilder'
|
3
|
-
s.version = '2.2.
|
3
|
+
s.version = '2.2.12'
|
4
4
|
s.authors = ['David Heinemeier Hansson', 'Pavel Pravosud']
|
5
5
|
s.email = ['david@37signals.com', 'pavel@pravosud.com']
|
6
6
|
s.summary = 'Create JSON structures via a Builder-style DSL'
|
data/lib/jbuilder.rb
CHANGED
@@ -18,18 +18,18 @@ class Jbuilder
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Yields a builder and automatically turns the result into a JSON string
|
21
|
-
def self.encode(*args
|
22
|
-
new(*args,
|
21
|
+
def self.encode(*args)
|
22
|
+
new(*args, &::Proc.new).target!
|
23
23
|
end
|
24
24
|
|
25
25
|
BLANK = Blank.new
|
26
26
|
|
27
|
-
def set!(key, value = BLANK, *args
|
28
|
-
result = if
|
27
|
+
def set!(key, value = BLANK, *args)
|
28
|
+
result = if ::Kernel.block_given?
|
29
29
|
if !_blank?(value)
|
30
30
|
# json.comments @post.comments { |comment| ... }
|
31
31
|
# { "comments": [ { ... }, { ... } ] }
|
32
|
-
_scope{ array! value,
|
32
|
+
_scope{ array! value, &::Proc.new }
|
33
33
|
else
|
34
34
|
# json.comments { ... }
|
35
35
|
# { "comments": ... }
|
@@ -174,11 +174,11 @@ class Jbuilder
|
|
174
174
|
# json.array! [1, 2, 3]
|
175
175
|
#
|
176
176
|
# [1,2,3]
|
177
|
-
def array!(collection = [], *attributes
|
177
|
+
def array!(collection = [], *attributes)
|
178
178
|
array = if collection.nil?
|
179
179
|
[]
|
180
|
-
elsif
|
181
|
-
_map_collection(collection,
|
180
|
+
elsif ::Kernel.block_given?
|
181
|
+
_map_collection(collection, &::Proc.new)
|
182
182
|
elsif attributes.any?
|
183
183
|
_map_collection(collection) { |element| extract! element, *attributes }
|
184
184
|
else
|
@@ -213,9 +213,9 @@ class Jbuilder
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
|
-
def call(object, *attributes
|
217
|
-
if
|
218
|
-
array! object,
|
216
|
+
def call(object, *attributes)
|
217
|
+
if ::Kernel.block_given?
|
218
|
+
array! object, &::Proc.new
|
219
219
|
else
|
220
220
|
extract! object, *attributes
|
221
221
|
end
|
@@ -9,9 +9,9 @@ class JbuilderTemplate < Jbuilder
|
|
9
9
|
|
10
10
|
self.template_lookup_options = { handlers: [:jbuilder] }
|
11
11
|
|
12
|
-
def initialize(context, *args
|
12
|
+
def initialize(context, *args)
|
13
13
|
@context = context
|
14
|
-
super(*args
|
14
|
+
super(*args)
|
15
15
|
end
|
16
16
|
|
17
17
|
def partial!(name_or_options, locals = {})
|
@@ -74,8 +74,8 @@ class JbuilderTemplate < Jbuilder
|
|
74
74
|
# json.cache_if! !admin?, @person, expires_in: 10.minutes do
|
75
75
|
# json.extract! @person, :name, :age
|
76
76
|
# end
|
77
|
-
def cache_if!(condition, *args
|
78
|
-
condition ? cache!(*args,
|
77
|
+
def cache_if!(condition, *args)
|
78
|
+
condition ? cache!(*args, &::Proc.new) : yield
|
79
79
|
end
|
80
80
|
|
81
81
|
protected
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|