Class: Rack::PageCaching::Middleware::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_page_caching/rack_page_caching.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, content_type = "text/html") ⇒ Page

Returns a new instance of Page.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rack_page_caching/rack_page_caching.rb', line 48

def initialize(body, content_type = "text/html")
  if body.is_a?(Array)
    raise ArgumentError.new("Multipart pages can not be cached!") if body.size > 1
    @body = body.first
  else
    @body = body
  end
  unless @body.nil?
    @body << "\n<!-- Page created at: #{Time.now} -->"
  end
  @content_type = content_type
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



45
46
47
# File 'lib/rack_page_caching/rack_page_caching.rb', line 45

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



46
47
48
# File 'lib/rack_page_caching/rack_page_caching.rb', line 46

def content_type
  @content_type
end

Instance Method Details

#to_sObject



61
62
63
# File 'lib/rack_page_caching/rack_page_caching.rb', line 61

def to_s
  @body
end