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.
-
#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.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 21 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.
38 39 40 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 38 def identifier=(arg) unwrap.identifier = Nanoc::Identifier.from(arg) end |
#update_attributes(hash) ⇒ self
Updates the attributes based on the given hash.
47 48 49 50 |
# File 'lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb', line 47 def update_attributes(hash) hash.each { |k, v| unwrap.attributes[k] = v } self end |