Exception: Foobara::Entity::NotFoundError
- Inherits:
-
RuntimeError
show all
- Defined in:
- foobara-0.5.8/projects/entities/projects/entity/src/not_found_error.rb
Instance Attribute Summary
#backtrace_when_initialized, #backtrace_when_raised, #context, #error_key, #is_fatal, #message
Class Method Summary
collapse
Instance Method Summary
collapse
category, fatal?, #initialize
#==, abstract, abstract?, category, #category, #category=, context, #eql?, fatal?, #fatal?, foobara_manifest, #initialize, #key, message, path, #path, #path=, #prepend_path!, runtime_path, #runtime_path, #runtime_path=, symbol, #symbol, #symbol=, to_h, #to_h, types_depended_on
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Class Method Details
.data_path ⇒ Object
45
46
47
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 45
def data_path
nil
end
|
.for(criteria, entity_class: self.entity_class, data_path: self.data_path || "") ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 34
def for(criteria, entity_class: self.entity_class, data_path: self.data_path || "")
message = "Could not find #{entity_class} for #{criteria}"
context = {
entity_class: entity_class.full_entity_name,
criteria:,
data_path: data_path.to_s
}
new(context:, message:)
end
|
.not_found_error_class_name(data_path) ⇒ Object
5
6
7
8
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 5
def not_found_error_class_name(data_path)
error_class_name = data_path.path.map { |part| part == :"#" ? "Collection" : Util.classify(part) }.join
"#{error_class_name}NotFoundError"
end
|
.subclass(mod, entity_class, data_path) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 10
def subclass(mod, entity_class, data_path)
error_class_name = not_found_error_class_name(data_path)
Util.make_class("#{mod.name}::#{error_class_name}", self) do
singleton_class.define_method :data_path do
data_path
end
singleton_class.define_method :entity_class do
entity_class
end
singleton_class.define_method :context_type_declaration do
{
entity_class: :string, criteria: :duck, data_path: :string }
end
end
end
|
Instance Method Details
#criteria ⇒ Object
68
69
70
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 68
def criteria
context[:criteria]
end
|
#data_path ⇒ Object
72
73
74
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 72
def data_path
context[:data_path]
end
|
#entity_class ⇒ Object
76
77
78
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 76
def entity_class
context[:entity_class]
end
|
#full_entity_name ⇒ Object
62
63
64
65
66
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 62
def full_entity_name
entity_class.full_entity_name
end
|
#primary_key_attribute ⇒ Object
56
57
58
59
60
|
# File 'projects/entities/projects/entity/src/not_found_error.rb', line 56
def primary_key_attribute
entity_class.primary_key_attribute
end
|