Module: Nanoc::DocumentViewMixin
- Included in:
- ItemWithoutRepsView, LayoutView
- Defined in:
- lib/nanoc/base/views/mixins/document_view_mixin.rb
Constant Summary
Instance Method Summary (collapse)
-
- (Object) ==(other)
(also: #eql?)
-
- (Object) [](key)
-
- (Hash) attributes
-
- (Object) fetch(key, fallback = NONE, &_block)
-
- (Object) hash
-
- (Nanoc::Identifier) identifier
-
- (Boolean) key?(key)
Instance Method Details
- (Object) ==(other) 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 |
- (Object) [](key)
34 35 36 37 38 39 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 34 def [](key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes[key] end |
- (Hash) attributes
42 43 44 45 46 47 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 42 def attributes Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes end |
- (Object) fetch(key, fallback = NONE, &_block)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 50 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] elsif !fallback.equal?(NONE) fallback elsif block_given? yield(key) else raise KeyError, "key not found: #{key.inspect}" end end |
- (Object) hash
24 25 26 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 24 def hash self.class.hash ^ identifier.hash end |
- (Nanoc::Identifier) identifier
29 30 31 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 29 def identifier unwrap.identifier end |
- (Boolean) key?(key)
66 67 68 69 70 71 |
# File 'lib/nanoc/base/views/mixins/document_view_mixin.rb', line 66 def key?(key) Nanoc::Int::NotificationCenter.post(:visit_started, unwrap) Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap) unwrap.attributes.key?(key) end |