Class: ViewComponent::DocsBuilderComponent::ErrorKlassDoc

Inherits:
Base
  • Object
show all
Defined in:
lib/view_component/docs_builder_component.rb

Constant Summary

Constants inherited from Base

Base::RESERVED_PARAMETER, Base::VC_INTERNAL_DEFAULT_FORMAT

Constants included from Translatable

Translatable::HTML_SAFE_TRANSLATION_KEY, Translatable::TRANSLATION_EXTENSIONS

Constants included from Slotable

Slotable::RESERVED_NAMES

Instance Attribute Summary

Attributes inherited from Base

#__vc_original_view_context

Instance Method Summary collapse

Methods inherited from Base

#__vc_request, #before_render, collection_counter_parameter, collection_iteration_parameter, collection_parameter, compile, compiled?, compiler, config, #content, #content?, #controller, counter_argument_present?, ensure_compiled, #format, #helpers, inherited, iteration_argument_present?, #method_missing, #output_postamble, #output_preamble, #render, #render?, #render_in, #render_parent, #render_parent_to_string, #request, #set_original_view_context, sidecar_files, strip_trailing_whitespace, strip_trailing_whitespace?, validate_collection_parameter!, validate_initialization_parameters!, #view_cache_dependencies, #virtual_path, with_collection, with_collection_parameter

Methods included from WithContentHelper

#with_content

Methods included from Translatable

#i18n_scope, #translate

Methods included from Slotable

#get_slot, #set_polymorphic_slot, #set_slot

Constructor Details

#initialize(error_klass, _show_types) ⇒ ErrorKlassDoc

Returns a new instance of ErrorKlassDoc.



14
15
16
# File 'lib/view_component/docs_builder_component.rb', line 14

def initialize(error_klass, _show_types)
  @error_klass = error_klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewComponent::Base

Instance Method Details

#callObject



26
27
28
29
30
31
32
# File 'lib/view_component/docs_builder_component.rb', line 26

def call
  <<~DOCS.chomp
    `#{klass_name}`

    #{error_message}
  DOCS
end

#error_messageObject



22
23
24
# File 'lib/view_component/docs_builder_component.rb', line 22

def error_message
  ViewComponent.const_get(@error_klass)
end

#klass_nameObject



18
19
20
# File 'lib/view_component/docs_builder_component.rb', line 18

def klass_name
  @error_klass.gsub("ViewComponent::", "").gsub("::MESSAGE", "")
end