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


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
37
38
39
# File 'lib/fortitude/widget/files.rb', line 12

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

  @tried_class_names = tried_class_names
  @filename = options[:filename]
  @magic_comment_texts = options[:magic_comment_texts]
  @resulting_objects = options[:resulting_objects]
  @class_names_to_try = options[:class_names_to_try]
  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. (We got back resulting objects: #{resulting_objects.inspect})

You can either pass the class name into this method via the :class_names_to_try option
(we were passed #{class_names_to_try.inspect}),
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

#class_names_to_tryObject (readonly)

Returns the value of attribute class_names_to_try


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

def class_names_to_try
  @class_names_to_try
end

#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

#resulting_objectsObject (readonly)

Returns the value of attribute resulting_objects


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

def resulting_objects
  @resulting_objects
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