module Nanoc::Core::DocumentViewMixin

Public Class Methods

new(document, context) click to toggle source

@api private

Calls superclass method
# File lib/nanoc/core/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/core/document_view_mixin.rb, line 18
def ==(other)
  other.respond_to?(:identifier) && identifier == other.identifier
end
[](key) click to toggle source

@see Hash#[]

# File lib/nanoc/core/document_view_mixin.rb, line 38
def [](key)
  @context.dependency_tracker.bounce(_unwrap, attributes: [key])
  _unwrap.attributes[key]
end
_unwrap() click to toggle source

@api private

# File lib/nanoc/core/document_view_mixin.rb, line 13
def _unwrap
  @document
end
attributes() click to toggle source

@return [Hash]

# File lib/nanoc/core/document_view_mixin.rb, line 44
def attributes
  # TODO: Refine dependencies
  @context.dependency_tracker.bounce(_unwrap, attributes: true)
  _unwrap.attributes
end
eql?(other) click to toggle source

@see Object#eql?

# File lib/nanoc/core/document_view_mixin.rb, line 23
def eql?(other)
  other.is_a?(self.class) && identifier.eql?(other.identifier)
end
fetch(key, fallback = Nanoc::Core::UNDEFINED) { |key| ... } click to toggle source

@see Hash#fetch

# File lib/nanoc/core/document_view_mixin.rb, line 51
def fetch(key, fallback = Nanoc::Core::UNDEFINED, &_block)
  @context.dependency_tracker.bounce(_unwrap, attributes: [key])

  if _unwrap.attributes.key?(key)
    _unwrap.attributes[key]
  elsif !Nanoc::Core::UNDEFINED.equal?(fallback)
    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/core/document_view_mixin.rb, line 28
def hash
  self.class.hash ^ identifier.hash
end
identifier() click to toggle source

@return [Nanoc::Core::Identifier]

# File lib/nanoc/core/document_view_mixin.rb, line 33
def identifier
  _unwrap.identifier
end
inspect() click to toggle source
# File lib/nanoc/core/document_view_mixin.rb, line 82
def inspect
  "<#{self.class} identifier=#{_unwrap.identifier}>"
end
key?(key) click to toggle source

@see Hash#key?

# File lib/nanoc/core/document_view_mixin.rb, line 66
def key?(key)
  @context.dependency_tracker.bounce(_unwrap, attributes: [key])
  _unwrap.attributes.key?(key)
end
raw_content() click to toggle source

@api private

# File lib/nanoc/core/document_view_mixin.rb, line 77
def raw_content
  @context.dependency_tracker.bounce(_unwrap, raw_content: true)
  _unwrap.content.string
end
reference() click to toggle source

@api private

# File lib/nanoc/core/document_view_mixin.rb, line 72
def reference
  _unwrap.reference
end