Exception: Fortitude::Widget::Files::CannotDetermineWidgetClassNameError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/fortitude/widget/files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tried_class_names, options = { }) ⇒ CannotDetermineWidgetClassNameError

Returns a new instance of CannotDetermineWidgetClassNameError.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fortitude/widget/files.rb', line 12

def initialize(tried_class_names, options = { })
  options.assert_valid_keys(:filename, :magic_comment_texts)

  @tried_class_names = tried_class_names
  @filename = options[:filename]
  @magic_comment_texts = options[:magic_comment_texts]
  from_what = filename ? "from the file '#{filename}'" : "from some Fortitude source code"

  super %{You asked for a Fortitude widget class #{from_what},
but we couldn't determine the class name of the widget that supposedly is inside.

We tried the following class names, in order:

#{tried_class_names.join("\n")}

...but none of them both existed and were a class that eventually inherits from
::Fortitude::Widget.

You can either pass the class name into this method via the :class_names_to_try option,
or add a "magic comment" to the source code of this widget that looks like this:

#!<token>: <class_name>

...where <token> is one of: #{magic_comment_texts.join(", ")}}
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



10
11
12
# File 'lib/fortitude/widget/files.rb', line 10

def filename
  @filename
end

#magic_comment_textsObject (readonly)

Returns the value of attribute magic_comment_texts.



10
11
12
# File 'lib/fortitude/widget/files.rb', line 10

def magic_comment_texts
  @magic_comment_texts
end

#tried_class_namesObject (readonly)

Returns the value of attribute tried_class_names.



10
11
12
# File 'lib/fortitude/widget/files.rb', line 10

def tried_class_names
  @tried_class_names
end