Module: Nanoc::Core::MutableDocumentViewMixin
- Included in:
- MutableItemView, MutableLayoutView
- Defined in:
- lib/nanoc/core/mutable_document_view_mixin.rb
Defined Under Namespace
Classes: DisallowedAttributeValueError
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
Sets the value for the given attribute.
-
#identifier=(arg) ⇒ Object
Sets the identifier to the given argument.
- #raw_content=(arg) ⇒ Object
-
#update_attributes(hash) ⇒ self
Updates the attributes based on the given hash.
Instance Method Details
#[]=(key, value) ⇒ Object
Sets the value for the given attribute.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 28 def []=(key, value) disallowed_value_classes = Set.new([ Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::CompilationItemView, Nanoc::Core::LayoutView, ]) if disallowed_value_classes.include?(value.class) raise DisallowedAttributeValueError.new(value) end _unwrap.set_attribute(key, value) end |
#identifier=(arg) ⇒ Object
Sets the identifier to the given argument.
45 46 47 |
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 45 def identifier=(arg) _unwrap.identifier = Nanoc::Core::Identifier.from(arg) end |
#raw_content=(arg) ⇒ Object
19 20 21 |
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 19 def raw_content=(arg) _unwrap.content = Nanoc::Core::Content.create(arg) end |
#update_attributes(hash) ⇒ self
Updates the attributes based on the given hash.
54 55 56 57 |
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 54 def update_attributes(hash) hash.each { |k, v| _unwrap.set_attribute(k, v) } self end |