Skip to content

Commit e5f57cf

Browse files
authored
Merge pull request #468 from r7kamura/feature/fix-ruby-2-7-warnings
Fix warnings on Ruby 2.7
2 parents fd65c71 + 454d697 commit e5f57cf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/jbuilder.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def self.encode(*args, &block)
2626
BLANK = Blank.new
2727
NON_ENUMERABLES = [ ::Struct, ::OpenStruct ].to_set
2828

29-
def set!(key, value = BLANK, *args)
29+
def set!(key, value = BLANK, *args, &block)
3030
result = if ::Kernel.block_given?
3131
if !_blank?(value)
3232
# json.comments @post.comments { |comment| ... }
3333
# { "comments": [ { ... }, { ... } ] }
34-
_scope{ array! value, &::Proc.new }
34+
_scope{ array! value, &block }
3535
else
3636
# json.comments { ... }
3737
# { "comments": ... }
@@ -61,9 +61,9 @@ def set!(key, value = BLANK, *args)
6161
_set_value key, result
6262
end
6363

64-
def method_missing(*args)
64+
def method_missing(*args, &block)
6565
if ::Kernel.block_given?
66-
set!(*args, &::Proc.new)
66+
set!(*args, &block)
6767
else
6868
set!(*args)
6969
end
@@ -181,11 +181,11 @@ def child!
181181
# json.array! [1, 2, 3]
182182
#
183183
# [1,2,3]
184-
def array!(collection = [], *attributes)
184+
def array!(collection = [], *attributes, &block)
185185
array = if collection.nil?
186186
[]
187187
elsif ::Kernel.block_given?
188-
_map_collection(collection, &::Proc.new)
188+
_map_collection(collection, &block)
189189
elsif attributes.any?
190190
_map_collection(collection) { |element| extract! element, *attributes }
191191
else
@@ -220,9 +220,9 @@ def extract!(object, *attributes)
220220
end
221221
end
222222

223-
def call(object, *attributes)
223+
def call(object, *attributes, &block)
224224
if ::Kernel.block_given?
225-
array! object, &::Proc.new
225+
array! object, &block
226226
else
227227
extract! object, *attributes
228228
end

lib/jbuilder/jbuilder_template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def cache_root!(key=nil, options={})
7373
# json.cache_if! !admin?, @person, expires_in: 10.minutes do
7474
# json.extract! @person, :name, :age
7575
# end
76-
def cache_if!(condition, *args)
77-
condition ? cache!(*args, &::Proc.new) : yield
76+
def cache_if!(condition, *args, &block)
77+
condition ? cache!(*args, &block) : yield
7878
end
7979

8080
def target!

0 commit comments

Comments
 (0)