Sha256: 1347823d8223a417ac99287727f51608fec6a49389831983c9da6b14d4e4ee73
Contents?: true
Size: 1022 Bytes
Versions: 3
Compression:
Stored size: 1022 Bytes
Contents
module Nanoc module MutableDocumentViewMixin # @api private class DisallowedAttributeValueError < Nanoc::Error attr_reader :value def initialize(value) @value = value end def message "The #{value.class} cannot be stored inside an attribute. Store its identifier instead." end end # Sets the value for the given attribute. # # @param [Symbol] key # # @see Hash#[]= def []=(key, value) disallowed_value_classes = Set.new([ Nanoc::Int::Item, Nanoc::Int::Layout, Nanoc::ItemView, Nanoc::LayoutView, ]) if disallowed_value_classes.include?(value.class) raise DisallowedAttributeValueError.new(value) end unwrap.attributes[key] = value end # Updates the attributes based on the given hash. # # @param [Hash] hash # # @return [self] def update_attributes(hash) hash.each { |k, v| unwrap.attributes[k] = v } self end end end
Version data entries
3 entries across 3 versions & 1 rubygems