Module: Nanoc::DocumentViewMixin
- Included in:
- ItemWithoutRepsView, LayoutView
- Defined in:
- lib/nanoc/base/views/mixins/document_view_mixin.rb
Constant Summary
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
-
#[](key) ⇒ Object
-
#attributes ⇒ Hash
-
#fetch(key, fallback = NONE, &_block) ⇒ Object
-
#hash ⇒ Object
-
#identifier ⇒ Nanoc::Identifier
-
#key?(key) ⇒ Boolean
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
18 19 20 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 18 def ==(other) other.respond_to?(:identifier) && identifier == other.identifier end |
#[](key) ⇒ Object
34 35 36 37 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 34 def [](key) @context.dependency_tracker.bounce(unwrap) unwrap.attributes[key] end |
#attributes ⇒ Hash
40 41 42 43 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 40 def attributes @context.dependency_tracker.bounce(unwrap) unwrap.attributes end |
#fetch(key, fallback = NONE, &_block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 46 def fetch(key, fallback = NONE, &_block) @context.dependency_tracker.bounce(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 ⇒ Object
24 25 26 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 24 def hash self.class.hash ^ identifier.hash end |
#identifier ⇒ Nanoc::Identifier
29 30 31 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 29 def identifier unwrap.identifier end |
#key?(key) ⇒ Boolean
61 62 63 64 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 61 def key?(key) @context.dependency_tracker.bounce(unwrap) unwrap.attributes.key?(key) end |