Class: ClassSource::MethodIndex
- Inherits:
-
Object
- Object
- ClassSource::MethodIndex
show all
- Defined in:
- lib/class_source/method_index.rb
Defined Under Namespace
Classes: ClassMethodIndex
Instance Method Summary
collapse
Constructor Details
#initialize(target_class) ⇒ MethodIndex
Returns a new instance of MethodIndex.
3
4
5
|
# File 'lib/class_source/method_index.rb', line 3
def initialize(target_class)
@target_class = target_class
end
|
Instance Method Details
#all(options = {}) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/class_source/method_index.rb', line 24
def all(options={})
include_inherited_methods = options.has_key?(:include_inherited_methods) ? options[:include_inherited_methods] : true
target = options[:target] || @target_class
target.public_instance_methods(include_inherited_methods) +
target.private_instance_methods(include_inherited_methods) +
target.protected_instance_methods(include_inherited_methods)
end
|
#klass ⇒ Object
32
33
34
|
# File 'lib/class_source/method_index.rb', line 32
def klass
ClassMethodIndex.new(@target_class)
end
|
#locations ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/class_source/method_index.rb', line 7
def locations
@locations ||= (unique.map do |m|
@target_class.instance_method(m).source_location
end + klass.unique.map do |m|
@target_class.method(m).source_location
end).compact
end
|
#unique ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/class_source/method_index.rb', line 15
def unique
uniquely_named_methods = all(:include_inherited_methods => false)
overridden_methods = (all - uniquely_named_methods).select do |m|
@target_class.instance_method(m).source_location != @target_class.superclass.instance_method(m).source_location
end
overridden_methods + uniquely_named_methods
end
|