Module: Nanoc::DocumentViewMixin
- Included in:
- ItemWithoutRepsView, LayoutView
- Defined in:
- lib/nanoc/base/views/mixins/document_view_mixin.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
-
#[](key) ⇒ Object
-
#attributes ⇒ Hash
-
#eql?(other) ⇒ Boolean
-
#fetch(key, fallback = NONE, &_block) ⇒ Object
-
#hash ⇒ Object
-
#identifier ⇒ Nanoc::Identifier
-
#inspect ⇒ Object
-
#key?(key) ⇒ Boolean
Instance Method Details
#==(other) ⇒ Object
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
38 39 40 41 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 38 def [](key) @context.dependency_tracker.bounce(unwrap, attributes: true) unwrap.attributes[key] end |
#attributes ⇒ Hash
44 45 46 47 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 44 def attributes @context.dependency_tracker.bounce(unwrap, attributes: true) unwrap.attributes end |
#eql?(other) ⇒ Boolean
23 24 25 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 23 def eql?(other) other.is_a?(self.class) && identifier.eql?(other.identifier) end |
#fetch(key, fallback = NONE, &_block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 50 def fetch(key, fallback = NONE, &_block) @context.dependency_tracker.bounce(unwrap, attributes: true) 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
28 29 30 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 28 def hash self.class.hash ^ identifier.hash end |
#identifier ⇒ Nanoc::Identifier
33 34 35 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 33 def identifier unwrap.identifier end |
#inspect ⇒ Object
81 82 83 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 81 def inspect "<#{self.class} identifier=#{unwrap.identifier}>" end |
#key?(key) ⇒ Boolean
65 66 67 68 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 65 def key?(key) @context.dependency_tracker.bounce(unwrap, attributes: true) unwrap.attributes.key?(key) end |