Options.fetch

This commit is contained in:
bootstraponline
2012-11-07 19:04:36 -07:00
parent 2686e96046
commit 74ce648c59
+25 -20
View File
@@ -166,26 +166,31 @@ module Gollum
options[:access] = path
path = path.path
end
@path = path
@repo_is_bare = options[:repo_is_bare]
@page_file_dir = options[:page_file_dir]
@access = options[:access] || GitAccess.new(path, @page_file_dir, @repo_is_bare)
@base_path = options[:base_path] || "/"
@page_class = options[:page_class] || self.class.page_class
@file_class = options[:file_class] || self.class.file_class
@markup_classes = options[:markup_classes] || self.class.markup_classes
@repo = @access.repo
@ref = options[:ref] || self.class.default_ref
@sanitization = options[:sanitization] || self.class.sanitization
@ws_subs = options[:ws_subs] ||
self.class.default_ws_subs
@history_sanitization = options[:history_sanitization] ||
self.class.history_sanitization
@live_preview = options[:live_preview] || true
@universal_toc = options[:universal_toc] || false
@mathjax = options[:mathjax] || false
@show_all = options[:show_all] || false
@collapse_tree = options[:collapse_tree] || false
# Use .fetch instead of ||
#
# o = { :a => false }
# o[:a] || true # => true
# o.fetch :a, true # => false
@path = path
@repo_is_bare = options.fetch :repo_is_bare, nil
@page_file_dir = options.fetch :page_file_dir, nil
@access = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare)
@base_path = options.fetch :base_path, "/"
@page_class = options.fetch :page_class, self.class.page_class
@file_class = options.fetch :file_class, self.class.file_class
@markup_classes = options.fetch :markup_classes, self.class.markup_classes
@repo = @access.repo
@ref = options.fetch :ref, self.class.default_ref
@sanitization = options.fetch :sanitization, self.class.sanitization
@ws_subs = options.fetch :ws_subs, self.class.default_ws_subs
@history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization
@live_preview = options.fetch :live_preview, true
@universal_toc = options.fetch :universal_toc, false
@mathjax = options.fetch :mathjax, false
@show_all = options.fetch :show_all, false
@collapse_tree = options.fetch :collapse_tree, false
end
# Public: check whether the wiki's git repo exists on the filesystem.