Replace BlankSlate with BasicObject for Builder 3.0.0 compatibility (#40802).

Patch by Pavel Rosický (@ahorek).


git-svn-id: https://svn.redmine.org/redmine/trunk@22863 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2024-06-07 04:47:53 +00:00
parent c1335f5126
commit d909b82d32
2 changed files with 9 additions and 11 deletions

View File

@@ -28,7 +28,7 @@ module Redmine
def initialize(request, response) def initialize(request, response)
super super
callback = request.params[:callback] || request.params[:jsonp] callback = request.params[:callback] || request.params[:jsonp]
if callback && Setting.jsonp_enabled? if callback && ::Setting.jsonp_enabled?
self.jsonp = callback.to_s.gsub(/[^a-zA-Z0-9_.]/, '') self.jsonp = callback.to_s.gsub(/[^a-zA-Z0-9_.]/, '')
end end
end end

View File

@@ -17,12 +17,10 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'blankslate'
module Redmine module Redmine
module Views module Views
module Builders module Builders
class Structure < BlankSlate class Structure < BasicObject
def initialize(request, response) def initialize(request, response)
@struct = [{}] @struct = [{}]
@request = request @request = request
@@ -38,7 +36,7 @@ module Redmine
end end
def encode_value(value) def encode_value(value)
if value.is_a?(Time) if value.is_a?(::Time)
# Rails uses a global setting to format JSON times # Rails uses a global setting to format JSON times
# Don't rely on it for the API as it could have been changed # Don't rely on it for the API as it could have been changed
value.xmlschema(0) value.xmlschema(0)
@@ -49,15 +47,15 @@ module Redmine
def method_missing(sym, *args, &block) def method_missing(sym, *args, &block)
if args.count > 0 if args.count > 0
if args.first.is_a?(Hash) if args.first.is_a?(::Hash)
if @struct.last.is_a?(Array) if @struct.last.is_a?(::Array)
@struct.last << args.first unless block @struct.last << args.first unless block
else else
@struct.last[sym] = args.first @struct.last[sym] = args.first
end end
else else
value = encode_value(args.first) value = encode_value(args.first)
if @struct.last.is_a?(Array) if @struct.last.is_a?(::Array)
if args.size == 1 && !block if args.size == 1 && !block
@struct.last << value @struct.last << value
else else
@@ -69,13 +67,13 @@ module Redmine
end end
end end
if block if block
@struct << (args.first.is_a?(Hash) ? args.first : {}) @struct << (args.first.is_a?(::Hash) ? args.first : {})
yield(self) yield(self)
ret = @struct.pop ret = @struct.pop
if @struct.last.is_a?(Array) if @struct.last.is_a?(::Array)
@struct.last << ret @struct.last << ret
else else
if @struct.last.has_key?(sym) && @struct.last[sym].is_a?(Hash) if @struct.last.has_key?(sym) && @struct.last[sym].is_a?(::Hash)
@struct.last[sym].merge! ret @struct.last[sym].merge! ret
else else
@struct.last[sym] = ret @struct.last[sym] = ret