Module: Nanoc::MutableDocumentViewMixin
- Included in:
- MutableItemView, MutableLayoutView
- Defined in:
- lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 27 def []=(key, value) disallowed_value_classes = Set.new([ Nanoc::Int::Item, Nanoc::Int::Layout, Nanoc::ItemWithRepsView, Nanoc::LayoutView, ]) if disallowed_value_classes.include?(value.class) raise DisallowedAttributeValueError.new(value) end unwrap.attributes[key] = value end |
#identifier=(arg) ⇒ Object
Sets the identifier to the given argument.
44 45 46 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 44 def identifier=(arg) unwrap.identifier = Nanoc::Identifier.from(arg) end |
#raw_content=(arg) ⇒ Object
18 19 20 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 18 def raw_content=(arg) unwrap.content = Nanoc::Int::Content.create(arg) end |
#update_attributes(hash) ⇒ self
Updates the attributes based on the given hash.
53 54 55 56 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 53 def update_attributes(hash) hash.each { |k, v| unwrap.attributes[k] = v } self end |