Class: ESI::Tag::Container

Inherits:
Base
  • Object
show all
Extended by:
Log
Includes:
Log
Defined in:
lib/esi/tag/container.rb

Direct Known Subclasses

Attempt, Except, Try

Constant Summary

Constants inherited from Base

Base::Validate

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes

Instance Method Summary collapse

Methods included from Log

log, log_debug, log_error, log_request, msg

Methods inherited from Base

#buffer, #close, create, #prepare_url_vars

Constructor Details

#initialize(router, headers, http_params, name, attrs, cache) ⇒ Container

Returns a new instance of Container.



13
14
15
16
17
# File 'lib/esi/tag/container.rb', line 13

def initialize(router,headers,http_params,name,attrs,cache)
  super
  @children = []
  @unclosed = nil
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



11
12
13
# File 'lib/esi/tag/container.rb', line 11

def cache
  @cache
end

#childrenObject (readonly)

Returns the value of attribute children.



11
12
13
# File 'lib/esi/tag/container.rb', line 11

def children
  @children
end

#closedObject (readonly)

Returns the value of attribute closed.



11
12
13
# File 'lib/esi/tag/container.rb', line 11

def closed
  @closed
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/esi/tag/container.rb', line 11

def name
  @name
end

Instance Method Details

#add_child(tag) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/esi/tag/container.rb', line 27

def add_child(tag)
  if @unclosed
    #puts "add as child of(#{self.name}): #{tag.name} #{tag.attributes.inspect} to #{@unclosed.name}"
    @unclosed.add_child(tag)
  else
    #puts "add: #{tag.name} #{tag.attributes.inspect} to #{self.name}"
    @unclosed = tag if tag.respond_to?(:add_child)
    @children << tag
  end
end

#close_child(output, name) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/esi/tag/container.rb', line 19

def close_child( output, name )
  name = name.sub(/esi:/,'')
  if @unclosed and @unclosed.name == name
    @unclosed.close( output )
    @unclosed = nil
  end
end