Sha256: 89d7e39bdcd7c8d1cd91fd828b777053eb9252c1d1c3c62a56daba1a0ce1fa5c

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

require 'erb'

module Pakyow
  class CallContext
    protected

    def presenter_handle_error(code)
      return if !config.app.errors_in_browser || req.format != :html
      response.body = [content_for_code(code)]
    end

    def content_for_code(code)
      content = ERB.new(File.read(path_for_code(code))).result(binding)
      page = Presenter::Page.new(:presenter, content, '/')
      composer = presenter.compose_at('/', page: page)
      composer.to_html
    end

    def path_for_code(code)
      File.join(
        File.expand_path('../../../', __FILE__),
        'views',
        'errors',
        code.to_s + '.erb'
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pakyow-presenter-0.11.3 pakyow-presenter/lib/pakyow/presenter/ext/call_context.rb
pakyow-presenter-0.11.2 pakyow-presenter/lib/pakyow/presenter/ext/call_context.rb
pakyow-presenter-0.11.1 pakyow-presenter/lib/pakyow/presenter/ext/call_context.rb
pakyow-presenter-0.11.0 pakyow-presenter/lib/pakyow/presenter/ext/call_context.rb