lib/mpatch/module.rb in mpatch-2.9.0 vs lib/mpatch/module.rb in mpatch-2.11.0
- old
+ new
@@ -34,28 +34,31 @@
::ObjectSpace.each_object(type_name) do |candidate|
begin
if !return_array.include?(candidate) && candidate != self
- case self.class.to_s
- when "Module"
+ #> can't make subclass of Class so == is enough
+ case true
+
+ when self.class == ::Module
return_array.push candidate if candidate.mixin_ancestors.include?(self)
- when "Class"
+ when self.class == ::Class
return_array.push candidate if candidate < self
end
end
rescue ::ArgumentError, ::NoMethodError
+
end
end
end
- return_array
+ return return_array
end
def alias_singleton_methods_from class_name, *sym_names
@@ -86,10 +89,27 @@
self.__send__ :define_method, sym_name, class_name.instance_method(sym_name)
end
end
+ def hello
+ "hello"
+ end
+
+ #convert class instance instance variables into a hash object
+ def convert_to_hash
+
+ tmp_hash= {}
+ self.class_variables.each do|var|
+ tmp_hash[var.to_s.delete("@@")] = self.class_variable_get(var)
+ end
+
+ return tmp_hash
+
+ end
+ alias :conv2hash :convert_to_hash
+
end
end
module Extend
@@ -102,11 +122,9 @@
module_function symbol
public symbol
end
end
-
- alias :ci2s :convert_instance_methods_to_singleton_methods
alias :instances2singletons :convert_instance_methods_to_singleton_methods
end
end