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#[]=


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

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:



39
40
41
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 39

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

#raw_content=(arg) ⇒ Object



19
20
21
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 19

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)


48
49
50
51
# File 'lib/nanoc/core/mutable_document_view_mixin.rb', line 48

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