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
20 21 22 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 20 def ==(other) other.respond_to?(:identifier) && identifier == other.identifier end |
#[](key) ⇒ Object
40 41 42 43 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 40 def [](key) @context.dependency_tracker.bounce(unwrap, attributes: [key]) unwrap.attributes[key] end |
#attributes ⇒ Hash
46 47 48 49 50 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 46 def attributes # TODO: Refine dependencies @context.dependency_tracker.bounce(unwrap, attributes: true) unwrap.attributes end |
#eql?(other) ⇒ Boolean
25 26 27 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 25 def eql?(other) other.is_a?(self.class) && identifier.eql?(other.identifier) end |
#fetch(key, fallback = NONE, &_block) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 53 def fetch(key, fallback = NONE, &_block) @context.dependency_tracker.bounce(unwrap, attributes: [key]) 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
30 31 32 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 30 def hash self.class.hash ^ identifier.hash end |
#identifier ⇒ Nanoc::Identifier
35 36 37 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 35 def identifier unwrap.identifier end |
#inspect ⇒ Object
84 85 86 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 84 def inspect "<#{self.class} identifier=#{unwrap.identifier}>" end |
#key?(key) ⇒ Boolean
68 69 70 71 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 68 def key?(key) @context.dependency_tracker.bounce(unwrap, attributes: [key]) unwrap.attributes.key?(key) end |