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

Instance Method Details

#[]=(key, value) ⇒ Object

Sets the value for the given attribute.

Parameters:

  • key (Symbol)

See Also:

  • Hash#[]=


26
27
28
29
30
31
32
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 26

def []=(key, value)
  if disallowed_value_class?(value.class)
    raise DisallowedAttributeValueError.new(value)
  end

  _unwrap.set_attribute(key, value)
end

#identifier=(arg) ⇒ Object

Sets the identifier to the given argument.

Parameters:



37
38
39
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 37

def identifier=(arg)
  _unwrap.identifier = Nanoc::Core::Identifier.from(arg)
end

#raw_content=(arg) ⇒ Object



17
18
19
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 17

def raw_content=(arg)
  _unwrap.content = Nanoc::Core::Content.create(arg)
end

#update_attributes(hash) ⇒ self

Updates the attributes based on the given hash.

Parameters:

Returns:

  • (self)


46
47
48
49
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 46

def update_attributes(hash)
  hash.each { |k, v| _unwrap.set_attribute(k, v) }
  self
end