Permalink
Browse files

Ruby 1.9: Module#constants, Module.*methods, Kernel.*_variables all r…

…eturns array of symbols instead of array of strings.

git grep -E "(methods|instance_variables|constants|instance_methods|public_instance_methods|protected_instance_methods|private_instance_methods|singleton_methods|protected_methods|private_methods|public_methods|global_variables|local_variables|class_variables).*\.include\?"
  • Loading branch information...
1 parent dc024be commit 93eae460499cfddf8326bb664b0f0e66d25fe6ed @jrafanie jrafanie committed May 4, 2012
@@ -38,7 +38,7 @@ def setiv2obj(obj, node, map)
end
def setiv2soap(node, obj, map)
- if obj.class.class_variables.include?('@@schema_element')
+ if obj.class.class_variables.any? { |v| v.to_s == '@@schema_element' }
setdefinediv2soap(node, obj, map)
else
# should we sort instance_variables? how?
@@ -542,7 +542,7 @@ def protect_threadvars(*symbols)
def class_schema_variable(sym, klass)
var = "@@#{sym}"
- klass.class_variables.include?(var) ? klass.class_eval(var) : nil
+ klass.class_variables.any? { |v| v.to_s == var } ? klass.class_eval(var) : nil
end
def protect_mapping(opt)
@@ -44,9 +44,8 @@ def assign_name(qname, modulepath = nil)
end
def check_classname(name)
- if Object.constants.include?(name)
- warn("created definition re-opens an existing toplevel class: #{name}. consider to use --module_path option of wsdl2ruby.rb")
- end
+ cname = Object.constants.detect { |c| c.to_s == name }
+ warn("created definition re-opens an existing toplevel class: #{name}. consider to use --module_path option of wsdl2ruby.rb") if cname
end
end
@@ -83,9 +83,9 @@ def setup_server
end
def setup_classdef
- if ::Object.constants.include?("Echo")
- ::Object.instance_eval { remove_const("Echo") }
- end
+ echo = ::Object.constants.detect { |c| c.to_s == "Echo" }
+ ::Object.instance_eval { remove_const(echo) } if echo
+
gen = WSDL::SOAP::WSDL2Ruby.new
gen.location = pathname("rpc.wsdl")
gen.basedir = DIR
@@ -26,9 +26,9 @@ def test_classdef
def test_marshal
# avoid name crash (<item> => an Item when a class Item is defined)
- if ::Object.constants.include?("Item")
- ::Object.instance_eval { remove_const("Item") }
- end
+ item = ::Object.constants.detect { |c| c.to_s == "Item" }
+ ::Object.instance_eval { remove_const(item) } if item
+
TestUtil.require(DIR, 'mysample.rb')
s1 = Section.new(1, "section1", "section 1", 1001, Question.new("q1"))
s2 = Section.new(2, "section2", "section 2", 1002, Question.new("q2"))
@@ -46,9 +46,9 @@ def setup_server
end
def setup_classdef
- if ::Object.constants.include?("Version_struct")
- ::Object.instance_eval { remove_const("Version_struct") }
- end
+ ver = ::Object.constants.detect { |c| c.to_s == "Version_struct" }
+ ::Object.instance_eval { remove_const(ver) } if ver
+
gen = WSDL::SOAP::WSDL2Ruby.new
gen.location = pathname("soapenc.wsdl")
gen.basedir = DIR

0 comments on commit 93eae46

Please sign in to comment.