This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
## Class#descendants
|
||||
|
||||
require 'facets/class/descendants'
|
||||
|
||||
The `Class#descendants` method returns a list of classes that are subclasses
|
||||
of a class.
|
||||
|
||||
a = Class.new
|
||||
b = Class.new(a)
|
||||
c = Class.new(b)
|
||||
|
||||
a.descendants.assert == [b,c]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
## Class#to_proc
|
||||
|
||||
require 'facets/class/to_proc'
|
||||
|
||||
The `Class#to_proc` method provides a convenient way to create new
|
||||
instances from a set of initialization data.
|
||||
|
||||
person = Struct.new(:name)
|
||||
people = ["joe"].map(&person)
|
||||
people[0].name.assert == "joe"
|
||||
|
||||
Reference in New Issue
Block a user