Skip to content

Commit

Permalink
Replace deprecated ProxyObject with BasicObject (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain authored Apr 29, 2024
1 parent 0919e3f commit 6732db4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
8 changes: 4 additions & 4 deletions lib/jbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _extract_method_values(object, attributes)

def _merge_block(key)
current_value = _blank? ? BLANK : @attributes.fetch(_key(key), BLANK)
raise NullError.build(key) if current_value.nil?
::Kernel.raise NullError.build(key) if current_value.nil?
new_value = _scope{ yield self }
_merge_values(current_value, new_value)
end
Expand All @@ -310,7 +310,7 @@ def _merge_values(current_value, updates)
elsif ::Hash === current_value && ::Hash === updates
current_value.deep_merge(updates)
else
raise MergeError.build(current_value, updates)
::Kernel.raise MergeError.build(current_value, updates)
end
end

Expand All @@ -331,8 +331,8 @@ def _format_keys(hash_or_array)
end

def _set_value(key, value)
raise NullError.build(key) if @attributes.nil?
raise ArrayError.build(key) if ::Array === @attributes
::Kernel.raise NullError.build(key) if @attributes.nil?
::Kernel.raise ArrayError.build(key) if ::Array === @attributes
return if @ignore_nil && value.nil? or _blank?(value)
@attributes = {} if _blank?
@attributes[_key(key)] = value
Expand Down
8 changes: 1 addition & 7 deletions lib/jbuilder/jbuilder.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
Jbuilder = Class.new(begin
require 'active_support/proxy_object'
ActiveSupport::ProxyObject
rescue LoadError
require 'active_support/basic_object'
ActiveSupport::BasicObject
end)
Jbuilder = Class.new(BasicObject)
6 changes: 3 additions & 3 deletions lib/jbuilder/jbuilder_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def cache!(key=nil, options={})
# # 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
Expand Down Expand Up @@ -148,11 +148,11 @@ def _render_partial_with_options(options)
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
Expand Down

0 comments on commit 6732db4

Please sign in to comment.