Class: Class
- Defined in:
- lib/rmtools/core/class.rb,
lib/rmtools/core/deprecation.rb
Instance Method Summary collapse
- #deprecate_method(old_method, new_method) ⇒ Object
- #method_proxy(*vars) ⇒ Object
- #my_instance_methods(filter = //) ⇒ Object
- #personal_instance_methods(filter = //) ⇒ Object
- #personal_methods(filter = //) ⇒ Object
-
#superclasses ⇒ Object
differs with #ancestors in that it doesn’t show included modules.
Instance Method Details
#deprecate_method(old_method, new_method) ⇒ Object
31 32 33 |
# File 'lib/rmtools/core/deprecation.rb', line 31 def deprecate_method old_method, new_method define_method(new_method) {|*argv| deprecate_method old_method, *argv} end |
#method_proxy(*vars) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rmtools/core/class.rb', line 6 def method_proxy *vars buffered_missing = instance_methods.grep(/method_missing/).sort.last || 'method_missing' # next arg overrides previous vars.each {|v| class_eval " alias #{buffered_missing.bump! '_'} method_missing def method_missing *args, &block #{v}.send *args, &block rescue NoMethodError #{buffered_missing} *args, &block end" } end |
#my_instance_methods(filter = //) ⇒ Object
24 25 26 |
# File 'lib/rmtools/core/class.rb', line 24 def my_instance_methods filter=// (self.public_instance_methods - Object.public_instance_methods).sort!.grep(filter) end |
#personal_instance_methods(filter = //) ⇒ Object
28 29 30 |
# File 'lib/rmtools/core/class.rb', line 28 def personal_instance_methods filter=// (self.public_instance_methods - self.superclass.public_instance_methods).sort!.grep(filter) end |
#personal_methods(filter = //) ⇒ Object
20 21 22 |
# File 'lib/rmtools/core/class.rb', line 20 def personal_methods filter=// (self.singleton_methods - self.superclass.singleton_methods).sort!.grep(filter) end |
#superclasses ⇒ Object
differs with #ancestors in that it doesn’t show included modules
33 34 35 |
# File 'lib/rmtools/core/class.rb', line 33 def superclasses superclass ? superclass.unfold(lambda {|c|!c}) {|c| [c.superclass, c]} : [] end |