lib/lite/ruby/struct.rb in lite-ruby-1.0.14 vs lib/lite/ruby/struct.rb in lite-ruby-1.0.15
- old
+ new
@@ -1,21 +1,23 @@
# frozen_string_literal: false
-class Struct
+if Lite::Ruby.configuration.monkey_patches.include?('struct')
+ class Struct
- def [](key)
- send(key)
- end
+ def [](key)
+ send(key)
+ end
- def []=(key, val)
- send("#{key}=", val)
- end
+ def []=(key, val)
+ send("#{key}=", val)
+ end
- def attributes
- each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
- end
+ def attributes
+ each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
+ end
- def replace(args)
- args.each_pair { |key, val| send("#{key}=", val) }
- end
+ def replace(args)
+ args.each_pair { |key, val| send("#{key}=", val) }
+ end
+ end
end