Class: Yoda::Store::Objects::MethodObject
- Inherits:
-
Base
- Object
- Base
- Yoda::Store::Objects::MethodObject
show all
- Defined in:
- lib/yoda/store/objects/method_object.rb
Defined Under Namespace
Classes: Connected
Constant Summary
collapse
- METHOD_SEPARATOR_PATTERN =
/[#.]|(::)/
Instance Attribute Summary collapse
Attributes inherited from Base
#document, #path, #primary_source, #sources, #tag_list
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, #address, #eql?, #hash, #merge, #meta_class_address, #namespace?, #with_connection
#==, #derive, #eql?, #hash, included, #to_json
#address
Constructor Details
#initialize(parameters: [], visibility: :public, overloads: [], **kwargs) ⇒ MethodObject
Returns a new instance of MethodObject.
64
65
66
67
68
69
70
|
# File 'lib/yoda/store/objects/method_object.rb', line 64
def initialize(parameters: [], visibility: :public, overloads: [], **kwargs)
super(**kwargs)
fail ArgumentError, visibility unless %i(public private protected)
@visibility = visibility.to_sym
@parameters = parameters
@overloads = overloads
end
|
Instance Attribute Details
#overloads ⇒ Array<Overload>
16
17
18
|
# File 'lib/yoda/store/objects/method_object.rb', line 16
def overloads
@overloads
end
|
#parameters ⇒ Array<(String, String)>
10
11
12
|
# File 'lib/yoda/store/objects/method_object.rb', line 10
def parameters
@parameters
end
|
#visibility ⇒ Symbol
13
14
15
|
# File 'lib/yoda/store/objects/method_object.rb', line 13
def visibility
@visibility
end
|
Class Method Details
.attr_names ⇒ Array<Symbol>
40
41
42
|
# File 'lib/yoda/store/objects/method_object.rb', line 40
def attr_names
super + %i(parameters visibility overloads)
end
|
.name_of_path(path) ⇒ String
29
30
31
|
# File 'lib/yoda/store/objects/method_object.rb', line 29
def name_of_path(path)
divide_by_separator(path)&.at(2)
end
|
.namespace_of_path(path) ⇒ String
23
24
25
|
# File 'lib/yoda/store/objects/method_object.rb', line 23
def namespace_of_path(path)
divide_by_separator(path)&.at(0)
end
|
.sep_of_path(path) ⇒ String?
35
36
37
|
# File 'lib/yoda/store/objects/method_object.rb', line 35
def sep_of_path(path)
divide_by_separator(path)&.at(1)
end
|
Instance Method Details
#kind ⇒ Object
101
102
103
|
# File 'lib/yoda/store/objects/method_object.rb', line 101
def kind
:method
end
|
#name ⇒ String
73
74
75
|
# File 'lib/yoda/store/objects/method_object.rb', line 73
def name
@name ||= MethodObject.name_of_path(path)
end
|
#namespace_path ⇒ String
83
84
85
|
# File 'lib/yoda/store/objects/method_object.rb', line 83
def namespace_path
@namespace_path ||= MethodObject.namespace_of_path(path)
end
|
#parent_address ⇒ String
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/yoda/store/objects/method_object.rb', line 88
def parent_address
@parent_address ||= begin
case MethodObject.sep_of_path(path)
when '#'
namespace_path
when '.', '::'
MetaClassObject.address_of(namespace_path)
else
fail TypeError
end
end
end
|
#sep ⇒ String
78
79
80
|
# File 'lib/yoda/store/objects/method_object.rb', line 78
def sep
@sep ||= MethodObject.sep_of_path(path)
end
|
#to_h ⇒ Object
105
106
107
108
109
110
111
|
# File 'lib/yoda/store/objects/method_object.rb', line 105
def to_h
super.merge(
parameters: parameters.to_a,
visibility: visibility,
overloads: overloads,
)
end
|