Class: ActionView::TemplateHandlers::Rails3View
- Inherits:
-
TemplateHandler
- Object
- TemplateHandler
- ActionView::TemplateHandlers::Rails3View
- Includes:
- Compilable
- Defined in:
- lib/fleximage/rails3_view.rb
Defined Under Namespace
Classes: TemplateDidNotReturnImage
Instance Method Summary collapse
Instance Method Details
#compile(template) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fleximage/rails3_view.rb', line 8 def compile(template) <<-CODE @template_format = :flexi controller.response.content_type ||= Mime::JPG result = #{template.source} requested_format = (params[:format] || :jpg).to_sym begin # Raise an error if object returned from template is not an image record unless result.class.include?(Fleximage::Model::InstanceMethods) raise TemplateDidNotReturnImage, ".flexi template was expected to return a model instance that acts_as_fleximage, but got an instance of instead." end # Figure out the proper format raise 'Image must be requested with an image type format. jpg, gif and png only are supported.' unless [:jpg, :gif, :png].include?(requested_format) result.output_image(:format => requested_format) rescue Exception => e e end CODE ensure GC.start end |