Sha256: b6b43d20694886c4cdeddec0ca5e21768d87d17ef3d12a2e81d5854b53e5e92c
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module Nanoc module DocumentViewMixin # @api private NONE = Object.new # @api private def initialize(document) @document = document end # @api private def unwrap @document end # @see Object#== def ==(other) identifier == other.identifier end alias_method :eql?, :== # @see Object#hash def hash self.class.hash ^ identifier.hash end # @return [Nanoc::Identifier] def identifier unwrap.identifier end # @see Hash#[] def [](key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes[key] end # @see Hash#fetch 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] else if !fallback.equal?(NONE) fallback elsif block_given? yield(key) else raise KeyError, "key not found: #{key.inspect}" end end end # @see Hash#key? def key?(key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes.key?(key) end # @api private def reference unwrap.reference end # @api private def raw_content unwrap.content.string end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nanoc-4.0.0rc2 | lib/nanoc/base/views/mixins/document_view_mixin.rb |
nanoc-4.0.0rc1 | lib/nanoc/base/views/mixins/document_view_mixin.rb |
nanoc-4.0.0b4 | lib/nanoc/base/views/mixins/document.rb |