Ruby项目文档与打包管理全解析
1. RDoc生成文档基础
RDoc可以根据简单的注释生成美观的HTML文档,且不影响纯文本注释的可读性。即使代码未注释,运行RDoc也能生成展示API结构的有用内容。若使用带有轻量级格式语法的注释代码生成文档,能获得更多信息。
1.1 PStore事务终止示例
以下是一个PStore事务终止的示例代码,展示了如何使用 abort 方法丢弃事务中的所有更改:
# Ends the current PStore#transaction, discarding any changes to the data
# store.
#
# == Example:
#
require "pstore"
store = PStore.new("data_file.pstore")
store.transaction do # begin transaction
store[:one] = 1 # this change is not applied, see below...
store[:two] = 2 # this change is not applied, see below...
store.abort # end transaction here, discard all changes
store[:three] = 3 # this change is never reached
end
# *WARNING*: This method is only valid in a PSt
超级会员免费看
订阅专栏 解锁全文

3381

被折叠的 条评论
为什么被折叠?



