Class: Mack::Rendering::Type::Public

Inherits:
Base show all
Defined in:
lib/mack/rendering/type/public.rb

Overview

Used to render files stored in the public directory. These files are NOT run through any engines and are returned ‘as is’.

Instance Attribute Summary

Attributes inherited from Base

#view_template

Instance Method Summary collapse

Methods inherited from Base

#capture, #controller_view_path, #find_engine, #find_file, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Mack::Rendering::Type::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mack::Rendering::Type::Base

Instance Method Details

#allow_layout?Boolean

No layouts should be used with this Mack::Rendering::Type

Returns:

  • (Boolean)


25
26
27
# File 'lib/mack/rendering/type/public.rb', line 25

def allow_layout?
  false
end

#renderObject

Attempts to find the file on disk and return it. If no file extension is provided then the ‘format’ of the request is appended to the file name.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mack/rendering/type/public.rb', line 11

def render
  p_file = self._render_value
  if File.extname(p_file).blank?
    p_file = "#{p_file}.#{self._options[:format]}"
  end
  Mack.search_path(:public).each do |path|
    find_file(File.join(path, p_file)) do |f|
      return File.open(f).read
    end
  end
  raise Mack::Errors::ResourceNotFound.new(p_file)
end