Class: Class
Overview
Monkey-patched Class class.
Instance Method Summary collapse
-
#includes_module?(mod) ⇒ Boolean
Checks for module inclusion.
-
#short_name ⇒ String
Name of class without the namespace.
-
#subclass_of?(klass) ⇒ Boolean
Checks to see if a Class object is a subclass of the given class.
Instance Method Details
#includes_module?(mod) ⇒ Boolean
Checks for module inclusion.
84 85 86 |
# File 'lib/rltk/util/monkeys.rb', line 84 def includes_module?(mod) self.included_modules.include?(mod) end |
#short_name ⇒ String
Returns Name of class without the namespace.
89 90 91 |
# File 'lib/rltk/util/monkeys.rb', line 89 def short_name self.name.split('::').last end |
#subclass_of?(klass) ⇒ Boolean
Checks to see if a Class object is a subclass of the given class.
96 97 98 99 100 101 102 103 104 |
# File 'lib/rltk/util/monkeys.rb', line 96 def subclass_of?(klass) raise 'The klass parameter must be an instance of Class.' if not klass.is_a?(Class) if (superklass = self.superclass) superklass == klass or superklass.subclass_of?(klass) else false end end |