Skip to content

Commit 5288e8a

Browse files
authored
Remove OpenStruct references from Jbuilder (#567)
1 parent acf44b8 commit 5288e8a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

lib/jbuilder.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
require 'jbuilder/errors'
66
require 'json'
77
require 'active_support/core_ext/hash/deep_merge'
8-
begin
9-
require 'ostruct'
10-
rescue LoadError
11-
end
128

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

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

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

356351
def _is_collection?(object)
357-
_object_respond_to?(object, :map, :count) && NON_ENUMERABLES.none?{ |klass| klass === object }
352+
_object_respond_to?(object, :map, :count) && !(::Struct === object)
358353
end
359354

360355
def _blank?(value=@attributes)

0 commit comments

Comments
 (0)