Module: MPatch
- Extended by:
- Include::Module
- Defined in:
- lib/mpatch.rb,
lib/mpatch/all.rb,
lib/mpatch/yml.rb,
lib/mpatch/hash.rb,
lib/mpatch/proc.rb,
lib/mpatch/array.rb,
lib/mpatch/class.rb,
lib/mpatch/method.rb,
lib/mpatch/module.rb,
lib/mpatch/object.rb,
lib/mpatch/random.rb,
lib/mpatch/string.rb,
lib/mpatch/integer.rb,
lib/mpatch/process.rb,
lib/mpatch/injector.rb
Defined Under Namespace
Class Method Summary collapse
- .inject_patches ⇒ Object (also: inject, patch!)
Methods included from Include::Module
alias_instance_methods_from, alias_singleton_methods_from, convert_to_hash, hello, inherited_by, mixin_ancestors, subclasses, submodules
Class Method Details
.inject_patches ⇒ Object Also known as: inject, patch!
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/mpatch/injector.rb', line 5 def inject_patches #begin # @@valid_inject_cmd.nil? #rescue ::NameError # return nil #end self.submodules.each do |module_name| method_name= module_name.to_s.split('::').last.downcase.to_s.to_sym module_name.__send__ :extend, MPatch::Include::Module module_name.submodules.each do |sub_module_name| constant= ::Object constant_name= sub_module_name.to_s.split('::').last array_of_target_constant= [] case true when sub_module_name.to_s.include?('And') sub_module_name.to_s.split('::').last.split('And').each do |tag_module| array_of_target_constant.push tag_module end else array_of_target_constant.push constant_name end array_of_target_constant.each do |name| begin target_constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name) target_constant.__send__ method_name, sub_module_name rescue ::NoMethodError => ex STDERR.puts ex end end end end end |