Class: Sitepress::Rendition

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

Overview

Encapsulates the data needed to render a resource from a controller. This lets us keep the functions in the controller more functional, which makes them easier to override by the end users.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, layout: nil) ⇒ Rendition

Returns a new instance of Rendition.



8
9
10
# File 'lib/sitepress/rendition.rb', line 8

def initialize(resource, layout: nil)
  @resource = resource
end

Instance Attribute Details

#layoutObject

Returns the value of attribute layout.



6
7
8
# File 'lib/sitepress/rendition.rb', line 6

def layout
  @layout
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/sitepress/rendition.rb', line 6

def output
  @output
end

#resourceObject

Returns the value of attribute resource.



6
7
8
# File 'lib/sitepress/rendition.rb', line 6

def resource
  @resource
end

Instance Method Details

#handlerObject



16
17
18
# File 'lib/sitepress/rendition.rb', line 16

def handler
  resource.handler
end

#mime_typeObject



12
13
14
# File 'lib/sitepress/rendition.rb', line 12

def mime_type
  resource.mime_type.to_s
end

#sourceObject



20
21
22
# File 'lib/sitepress/rendition.rb', line 20

def source
  resource.body
end