Module: MethodReflect::MethodExtensions

Included in:
Method, Proc, UnboundMethod
Defined in:
lib/method_reflect.rb

Instance Method Summary collapse

Instance Method Details

#code_objectObject



14
15
16
17
18
19
20
21
# File 'lib/method_reflect.rb', line 14

def code_object
  if @code_object == nil
    YARD::Registry.clear
    YARD::parse_string(commented_source)
    @code_object = YARD::Registry.first
  end
  @code_object
end

#commented_sourceObject



7
8
9
10
11
12
# File 'lib/method_reflect.rb', line 7

def commented_source
  if @commented_source == nil
    @commented_source = self.comment + self.source
  end
  @commented_source
end

#docstringObject



23
24
25
26
27
28
# File 'lib/method_reflect.rb', line 23

def docstring
  if @docstring == nil
    @docstring = code_object.docstring
  end
  @docstring
end

#docstring_summaryObject



30
31
32
33
34
35
# File 'lib/method_reflect.rb', line 30

def docstring_summary
  if @docstring_summary == nil
    @docstring_summary = code_object.docstring.summary
  end
  @docstring_summary
end

#docstring_tagsObject



37
38
39
40
41
42
43
44
# File 'lib/method_reflect.rb', line 37

def docstring_tags
  if @docstring_tags == nil
    @docstring_tags = docstring.tags.map { |t|
      {name: t.name, tag_name: t.tag_name, text: t.text, types: t.types}
    }
  end
  @docstring_tags
end

#parameter_defaultsObject



53
54
55
56
57
58
# File 'lib/method_reflect.rb', line 53

def parameter_defaults
  if @parameter_defaults == nil
    @parameter_defaults = code_object.parameters.map{|n,d| [n.to_sym, d]}
  end
  @parameter_defaults
end

#scopeObject



67
68
69
70
71
72
# File 'lib/method_reflect.rb', line 67

def scope
  if @scope == nil
    @scope = code_object.scope
  end
  @scope
end

#signatureObject



46
47
48
49
50
51
# File 'lib/method_reflect.rb', line 46

def signature
  if @signature == nil
    @signature = code_object.signature
  end
  @signature
end

#visibilityObject



60
61
62
63
64
65
# File 'lib/method_reflect.rb', line 60

def visibility
  if @visibility == nil
    @visibility = code_object.visibility
  end
  @visibility
end