save_class(klass)
public
Writes the ri data for klass
Show source
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
ancestors = klass.ancestors.compact.map do |ancestor|
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