@@ -71,7 +71,7 @@ def on_command(name, *args)
71
71
"has_one" , "has_many" ,
72
72
"belongs_to" , "has_and_belongs_to_many" ,
73
73
"scope" , "named_scope" ,
74
- "public_class_method" , "private_class_method" ,
74
+ "public_class_method" , "private_class_method" , "protected_class_method" ,
75
75
"public" , "protected" , "private" ,
76
76
/^[mc]?attr_(accessor|reader|writer)$/
77
77
on_method_add_arg ( [ :fcall , name ] , args [ 0 ] )
@@ -171,18 +171,22 @@ def on_method_add_arg(call, args)
171
171
[ :alias , args [ 1 ] [ 0 ] , args [ 2 ] [ 0 ] , line ] if args [ 1 ] && args [ 2 ]
172
172
when "define_method"
173
173
[ :def , args [ 1 ] [ 0 ] , line ]
174
- when "public_class_method" , "private_class_method" , "private" , "public" , "protected"
174
+ when "public_class_method" , "private_class_method" , "protected_class_method" , " private", "public" , "protected"
175
175
access = name . sub ( "_class_method" , "" )
176
+ klass = name == access ? nil : 'self'
177
+ procedure = :def_with_access
176
178
177
- if args [ 1 ] [ 1 ] == 'self'
178
- klass = 'self'
179
+ if args [ 1 ] [ 0 ] . is_a? ( String )
180
+ procedure = :redefine_access
181
+ method_name = args [ 1 ] [ 0 ]
182
+ elsif args [ 1 ] [ 1 ] == 'self'
179
183
method_name = args [ 1 ] [ 2 ]
180
184
else
181
185
klass = nil
182
186
method_name = args [ 1 ] [ 1 ]
183
187
end
184
188
185
- [ :def_with_access , klass , method_name , access , line ]
189
+ [ procedure , klass , method_name , access , line ]
186
190
when "scope" , "named_scope"
187
191
[ :rails_def , :scope , args [ 1 ] [ 0 ] , line ]
188
192
when /^[mc]?attr_(accessor|reader|writer)$/
@@ -457,6 +461,14 @@ def on_def_with_access(klass, name, access, line)
457
461
:access => access
458
462
end
459
463
464
+ def on_redefine_access ( klass , name , access , line )
465
+ ns = ( @namespace . empty? ? 'Object' : @namespace . join ( '::' ) )
466
+ singleton = @is_singleton || klass == 'self'
467
+ full_name = "#{ ns } #{ singleton ? '.' : '#' } #{ name } "
468
+ tag = @tags . select { |t | t [ :full_name ] == full_name } . last
469
+ tag [ :access ] = access if tag
470
+ end
471
+
460
472
def on_rails_def ( kind , name , line )
461
473
ns = ( @namespace . empty? ? 'Object' : @namespace . join ( '::' ) )
462
474
0 commit comments