method
save_class
v1_9_2_180 -
Show latest stable
- Class:
RDoc::RI::Store
save_class(klass)public
Writes the ri data for klass
# File lib/rdoc/ri/store.rb, line 187
def save_class klass
FileUtils.mkdir_p class_path(klass.full_name)
@cache[:modules] << klass.full_name
path = class_file klass.full_name
begin
disk_klass = nil
open path, 'rb' do |io|
disk_klass = Marshal.load io.read
end
klass.merge disk_klass
rescue Errno::ENOENT
end
# BasicObject has no ancestors
ancestors = klass.ancestors.compact.map do |ancestor|
# HACK for classes we don't know about (class X < RuntimeError)
String === ancestor ? ancestor : ancestor.full_name
end
@cache[:ancestors][klass.full_name] ||= []
@cache[:ancestors][klass.full_name].push(*ancestors)
attributes = klass.attributes.map do |attribute|
"#{attribute.type} #{attribute.name}"
end
unless attributes.empty? then
@cache[:attributes][klass.full_name] ||= []
@cache[:attributes][klass.full_name].push(*attributes)
end
open path, 'wb' do |io|
Marshal.dump klass, io
end
end Related methods
- Instance methods
- ancestors
- attributes
- cache_path
- class_file
- class_methods
- class_path
- friendly_path
- inspect
- instance_methods
- load_cache
- load_class
- load_method
- method_file
- modules
- save_cache
- save_class
- save_method
- Class methods
- new