Class: ESI::Tag::Include

Inherits:
Base
  • Object
show all
Defined in:
lib/esi/tag/include.rb

Defined Under Namespace

Classes: Request

Constant Summary

Constants inherited from Base

Base::Validate

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #cache, #children, #closed, #name

Instance Method Summary collapse

Methods inherited from Base

#buffer, create, #prepare_url_vars

Methods included from Log

#log, #log_debug, #log_error, #log_request, #msg

Constructor Details

#initialize(uri, headers, http_params, name, attrs, cache) ⇒ Include

Returns a new instance of Include.



71
72
73
74
75
# File 'lib/esi/tag/include.rb', line 71

def initialize(uri,headers,http_params,name,attrs,cache)
  super
  @depth = 0
  @max_depth = 3
end

Instance Attribute Details

#depthObject

Returns the value of attribute depth.



69
70
71
# File 'lib/esi/tag/include.rb', line 69

def depth
  @depth
end

#max_depthObject

Returns the value of attribute max_depth.



69
70
71
# File 'lib/esi/tag/include.rb', line 69

def max_depth
  @max_depth
end

Instance Method Details

#close(output, options = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/esi/tag/include.rb', line 81

def close( output, options = {} )
  super(output)
  @output = output

  raise_on_error = options[:raise] || false # default to false

  src = @router.url_for(prepare_url_vars(@attributes["src"]))
  alt = @attributes['alt']
  alt = @router.url_for(prepare_url_vars(alt)) if alt

  prepare_parser

  if @cache.cached?( src, @http_params )
    send_from_cache( src )
  else
    send_from_origin( src, alt, raise_on_error )
  end

end

#parse_fragment?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/esi/tag/include.rb', line 77

def parse_fragment?
  @depth <= @max_depth
end