10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/yard-activerecord2/fields/field_handler.rb', line 10
def process
return unless statement.namespace.jump(:ident).source == 't'
method_name = call_params.first
class_name = caller_method.capitalize
return if method_name['_id']
if class_name == "Datetime"
class_name = "DateTime"
end
ensure_loaded! P(globals.klass)
namespace = P(globals.klass)
return if namespace.nil?
r_object = YARD::CodeObjects::MethodObject.new(namespace, method_name)
r_object.docstring = description(method_name)
r_object.docstring.add_tag get_tag(:return, '', class_name)
r_object.dynamic = true
register r_object
w_object = YARD::CodeObjects::MethodObject.new(namespace, "#{method_name}=")
w_object.docstring = description(method_name)
w_object.docstring.add_tag get_tag(:return, '', class_name)
w_object.dynamic = true
register w_object
namespace.instance_attributes[method_name.to_sym] = {
read: r_object,
write: w_object
}
end
|