Module: Nanoc::MutableDocumentViewMixin

Included in:
MutableItemView, MutableLayoutView
Defined in:
lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) []=(key, value)

Sets the value for the given attribute.

Parameters:

  • key (Symbol)

See Also:

  • Hash#[]=


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

- (Object) identifier=(arg)

Sets the identifier to the given argument.

Parameters:



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

- (self) update_attributes(hash)

Updates the attributes based on the given hash.

Parameters:

  • hash (Hash)

Returns:

  • (self)


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