Class: Class
Overview
Classes and Modules #
Instance Method Summary collapse
-
#as(binding_pattern) ⇒ Object
Causes an instance of a class to be bound the the given name.
-
#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
#as(binding_pattern) ⇒ Object
Causes an instance of a class to be bound the the given name.
646 647 648 |
# File 'lib/filigree/match.rb', line 646 def as(binding_pattern) binding_pattern.tap { |bp| bp.pattern_elem = Filigree::InstancePattern.new(self) } end |
#includes_module?(mod) ⇒ Boolean
Checks for module inclusion.
25 26 27 |
# File 'lib/filigree/class.rb', line 25 def includes_module?(mod) self.included_modules.include?(mod) end |
#short_name ⇒ String
Returns Name of class without the namespace.
30 31 32 |
# File 'lib/filigree/class.rb', line 30 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.
39 40 41 42 43 44 45 46 47 |
# File 'lib/filigree/class.rb', line 39 def subclass_of?(klass) check_type(klass, Class, 'klass') if (superklass = self.superclass) superklass == klass or superklass.subclass_of?(klass) else false end end |