@@ -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
0 commit comments