method_man 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/method_object/version.rb +1 -1
- data/lib/method_object.rb +5 -10
- metadata +1 -1
data/lib/method_object.rb
CHANGED
@@ -20,6 +20,10 @@ class MethodObject
|
|
20
20
|
block_parameter.fetch(1)
|
21
21
|
end
|
22
22
|
|
23
|
+
def parameter_names
|
24
|
+
@parameter_names ||= parameters.map(&:last)
|
25
|
+
end
|
26
|
+
|
23
27
|
def non_block_parameter_names
|
24
28
|
@non_block_parameter_names ||= non_block_parameters.map { |parameter| parameter.fetch(1) }
|
25
29
|
end
|
@@ -39,20 +43,11 @@ class MethodObject
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def add_getters
|
42
|
-
|
43
|
-
add_block_getter if block_parameter
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_parameter_getters
|
47
|
-
non_block_parameter_names.each do |parameter_name|
|
46
|
+
parameter_names.each do |parameter_name|
|
48
47
|
method_object_class.send(:attr_reader, parameter_name)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
def add_block_getter
|
53
|
-
method_object_class.send(:attr_reader, block_name)
|
54
|
-
end
|
55
|
-
|
56
51
|
def parameters
|
57
52
|
method_object_class.instance_method(:call).parameters
|
58
53
|
end
|