Class: Brut::FrontEnd::Pages::MissingPage

Inherits:
Brut::FrontEnd::Page show all
Defined in:
lib/brut/front_end/pages/missing_page.rb

Overview

Used in development when a route has been mapped, but no class exists for the page. This renders a hopefully helpful message in the browser to allow the developer to know what next steps to take.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Brut::FrontEnd::Page

#before_generate, #handle!, page_name, #page_name, #page_template, #view_template

Methods included from HandlingResults

#http_status, #redirect_to

Methods inherited from Component

component_name, #component_name

Methods included from Component::Helpers

#global_component, #inline_svg

Methods included from I18n::ForHTML

#html_escape, #t

Methods included from I18n::BaseMethods

#l, #t, #t_direct, #this_field_value

Methods included from Brut::Framework::Errors

#abstract_method!, #bug!

Constructor Details

#initialize(route:) ⇒ MissingPage

Returns a new instance of MissingPage.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brut/front_end/pages/missing_page.rb', line 12

def initialize(route:)
  @class_name = route.exception.class_name_path.join("::")
  @path_template = route.path_template
  parts = route.exception.class_name_path.map { |part|
    RichString.new(part).underscorized.to_s
  }
  last_part = parts[-1]
  parts[-1] = last_part + ".rb"
  if route.class == Brut::FrontEnd::Routing::MissingForm
    @scaffold_command       = "form"
    @types_of_files_created = "form class, handler class, and test"
  elsif route.class == Brut::FrontEnd::Routing::MissingPage
    @scaffold_command       = "page"
    @types_of_files_created = "page class, HTML template, and test"
  elsif route.class == Brut::FrontEnd::Routing::MissingPath
    @scaffold_command       = "handler"
    @types_of_files_created = "handler class, and test"
  else
    nil
  end
end

Instance Attribute Details

#class_fileObject (readonly)

Returns the value of attribute class_file.



6
7
8
# File 'lib/brut/front_end/pages/missing_page.rb', line 6

def class_file
  @class_file
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



6
7
8
# File 'lib/brut/front_end/pages/missing_page.rb', line 6

def class_name
  @class_name
end

#path_templateObject (readonly)

Returns the value of attribute path_template.



6
7
8
# File 'lib/brut/front_end/pages/missing_page.rb', line 6

def path_template
  @path_template
end

#scaffold_commandObject (readonly)

Returns the value of attribute scaffold_command.



6
7
8
# File 'lib/brut/front_end/pages/missing_page.rb', line 6

def scaffold_command
  @scaffold_command
end

#types_of_files_createdObject (readonly)

Returns the value of attribute types_of_files_created.



6
7
8
# File 'lib/brut/front_end/pages/missing_page.rb', line 6

def types_of_files_created
  @types_of_files_created
end

Instance Method Details

#layoutObject



34
# File 'lib/brut/front_end/pages/missing_page.rb', line 34

def layout = "_internal"

#template_nameObject



35
# File 'lib/brut/front_end/pages/missing_page.rb', line 35

def template_name = "_missing_page"