lib/nanoc/base/views/mixins/document_view_mixin.rb in nanoc-4.1.1 vs lib/nanoc/base/views/mixins/document_view_mixin.rb in nanoc-4.1.2
- old
+ new
@@ -1,9 +1,9 @@
module Nanoc
module DocumentViewMixin
# @api private
- NONE = Object.new
+ NONE = Object.new.freeze
# @api private
def initialize(document, context)
super(context)
@document = document
@@ -16,11 +16,11 @@
# @see Object#==
def ==(other)
other.respond_to?(:identifier) && identifier == other.identifier
end
- alias_method :eql?, :==
+ alias eql? ==
# @see Object#hash
def hash
self.class.hash ^ identifier.hash
end
@@ -51,17 +51,15 @@
Nanoc::Int::NotificationCenter.post(:visit_started, unwrap)
Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap)
if unwrap.attributes.key?(key)
unwrap.attributes[key]
+ elsif !fallback.equal?(NONE)
+ fallback
+ elsif block_given?
+ yield(key)
else
- if !fallback.equal?(NONE)
- fallback
- elsif block_given?
- yield(key)
- else
- raise KeyError, "key not found: #{key.inspect}"
- end
+ raise KeyError, "key not found: #{key.inspect}"
end
end
# @see Hash#key?
def key?(key)