lib/jbuilder/jbuilder_template.rb in jbuilder-2.11.5 vs lib/jbuilder/jbuilder_template.rb in jbuilder-2.12.0
- old
+ new
@@ -87,11 +87,11 @@
# end
#
# # json.extra 'This will not work either, the root must be exclusive'
def cache_root!(key=nil, options={})
if @context.controller.perform_caching
- raise "cache_root! can't be used after JSON structures have been defined" if @attributes.present?
+ ::Kernel.raise "cache_root! can't be used after JSON structures have been defined" if @attributes.present?
@cached_root = _cache_fragment_for([ :root, key ], options) { yield; target! }
else
yield
end
@@ -143,16 +143,17 @@
if as && options.key?(:collection) && CollectionRenderer.supported?
collection = options.delete(:collection) || []
partial = options.delete(:partial)
options[:locals].merge!(json: self)
+ collection = EnumerableCompat.new(collection) if collection.respond_to?(:count) && !collection.respond_to?(:size)
if options.has_key?(:layout)
- raise ::NotImplementedError, "The `:layout' option is not supported in collection rendering."
+ ::Kernel.raise ::NotImplementedError, "The `:layout' option is not supported in collection rendering."
end
if options.has_key?(:spacer_template)
- raise ::NotImplementedError, "The `:spacer_template' option is not supported in collection rendering."
+ ::Kernel.raise ::NotImplementedError, "The `:spacer_template' option is not supported in collection rendering."
end
results = CollectionRenderer
.new(@context.lookup_context, options) { |&block| _scope(&block) }
.render_collection_with_partial(collection, partial, @context, nil)