Module: Utopia::Content::Namespace

Included in:
Tags
Defined in:
lib/utopia/content/namespace.rb

Overview

A namespace which contains tags which can be rendered within a Document.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#namedObject (readonly)

Returns the value of attribute named.



31
32
33
# File 'lib/utopia/content/namespace.rb', line 31

def named
  @named
end

Class Method Details

.extended(other) ⇒ Object



25
26
27
28
29
# File 'lib/utopia/content/namespace.rb', line 25

def self.extended(other)
  other.class_exec do
    @named = {}
  end
end

Instance Method Details

#call(name, node) ⇒ Node

Returns The node which should be used to render the named tag.

Returns:

  • (Node)

    The node which should be used to render the named tag.



47
48
49
# File 'lib/utopia/content/namespace.rb', line 47

def call(name, node)
  @named[name]
end

#freezeObject



33
34
35
36
37
38
39
40
# File 'lib/utopia/content/namespace.rb', line 33

def freeze
  return self if frozen?
  
  @named.freeze
  @named.values.each(&:freeze)
  
  super
end

#tag(name, klass = nil, &block) ⇒ Object



42
43
44
# File 'lib/utopia/content/namespace.rb', line 42

def tag(name, klass = nil, &block)
  @named[name] = klass || block
end