Skip to content

Commit

Permalink
Remove OpenStruct references from Jbuilder (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsmfm authored Sep 15, 2024
1 parent acf44b8 commit 5288e8a
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/jbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
require 'jbuilder/errors'
require 'json'
require 'active_support/core_ext/hash/deep_merge'
begin
require 'ostruct'
rescue LoadError
end

class Jbuilder
@@key_formatter = nil
Expand All @@ -31,7 +27,6 @@ def self.encode(*args, &block)
end

BLANK = Blank.new
NON_ENUMERABLES = defined?(::OpenStruct) ? [::Struct, ::OpenStruct].to_set : [::Struct].to_set

def set!(key, value = BLANK, *args, &block)
result = if ::Kernel.block_given?
Expand Down Expand Up @@ -354,7 +349,7 @@ def _scope
end

def _is_collection?(object)
_object_respond_to?(object, :map, :count) && NON_ENUMERABLES.none?{ |klass| klass === object }
_object_respond_to?(object, :map, :count) && !(::Struct === object)
end

def _blank?(value=@attributes)
Expand Down

0 comments on commit 5288e8a

Please sign in to comment.