module Nanoc::DocumentViewMixin
Constants
- NONE
@api private
Public Class Methods
new(document, context)
click to toggle source
@api private
Calls superclass method
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 7 def initialize(document, context) super(context) @document = document end
Public Instance Methods
==(other)
click to toggle source
@see Object#==
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 18 def ==(other) other.respond_to?(:identifier) && identifier == other.identifier end
Also aliased as: eql?
[](key)
click to toggle source
@see Hash#[]
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 34 def [](key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes[key] end
attributes()
click to toggle source
@return [Hash]
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 42 def attributes Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes end
fetch(key, fallback = NONE) { |key| ... }
click to toggle source
@see Hash#fetch
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 50 def fetch(key, fallback = NONE, &_block) 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 raise KeyError, "key not found: #{key.inspect}" end end
hash()
click to toggle source
@see Object#hash
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 24 def hash self.class.hash ^ identifier.hash end
identifier()
click to toggle source
@return [Nanoc::Identifier]
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 29 def identifier unwrap.identifier end
key?(key)
click to toggle source
@see Hash#key?
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 66 def key?(key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes.key?(key) end
raw_content()
click to toggle source
@api private
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 79 def raw_content unwrap.content.string end
reference()
click to toggle source
@api private
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 74 def reference unwrap.reference end
unwrap()
click to toggle source
@api private
# File lib/nanoc/base/views/mixins/document_view_mixin.rb, line 13 def unwrap @document end