Class: Class

Inherits:
Object show all
Defined in:
lib/filigree/class.rb,
lib/filigree/match.rb

Overview

Classes and Modules #

Instance Method Summary collapse

Instance Method Details

#as(binding_pattern) ⇒ Object

Causes an instance of a class to be bound the the given name.

Parameters:

  • binding_pattern (BindingPattern)

    Name to bind the instance to



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.

Parameters:

  • mod (Module)

    Module to check the inclusion of.

Returns:

  • (Boolean)

    If the module was included



25
26
27
# File 'lib/filigree/class.rb', line 25

def includes_module?(mod)
	self.included_modules.include?(mod)
end

#short_nameString

Returns Name of class without the namespace.

Returns:

  • (String)

    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.

Parameters:

  • klass (Class)

    Class we are checking if this is a subclass of.

Returns:

  • (Boolean)

    If self is a subclass of klass



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