Module: WashoutBuilder::Document::ExceptionModel
- Extended by:
- ActiveSupport::Concern
- Includes:
- SharedComplexType
- Defined in:
- lib/washout_builder/document/exception_model.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#get_complex_type_ancestors
Instance Method Details
#check_valid_fault_method?(method) ⇒ Boolean
40
41
42
43
44
45
|
# File 'lib/washout_builder/document/exception_model.rb', line 40
def check_valid_fault_method?(method)
method != :== && method != :! &&
( self.instance_methods.include?(:"#{method}=") ||
self.instance_methods.include?(:"#{method}")
)
end
|
#fault_ancestor_hash(structure, ancestors) ⇒ Object
32
33
34
|
# File 'lib/washout_builder/document/exception_model.rb', line 32
def fault_ancestor_hash( structure, ancestors)
{:fault => self,:structure =>structure ,:ancestors => ancestors }
end
|
#fault_ancestors ⇒ Object
28
29
30
|
# File 'lib/washout_builder/document/exception_model.rb', line 28
def fault_ancestors
get_complex_type_ancestors(self, ["ActiveRecord::Base", "Object", "BasicObject", "Exception" ])
end
|
#fault_without_inheritable_elements(ancestors) ⇒ Object
24
25
26
|
# File 'lib/washout_builder/document/exception_model.rb', line 24
def fault_without_inheritable_elements(ancestors)
remove_fault_type_inheritable_elements( ancestors[0].get_fault_model_structure.keys)
end
|
#get_fault_attributes ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/washout_builder/document/exception_model.rb', line 48
def get_fault_attributes
attrs = []
attrs = self.instance_methods(nil).collect do |method|
method.to_s if check_valid_fault_method?(method)
end
attrs = attrs.delete_if {|method| method.end_with?("=") && attrs.include?(method.gsub("=",'')) }
attrs.concat(["message", "backtrace"])
end
|
#get_fault_class_ancestors(defined, debug = false) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/washout_builder/document/exception_model.rb', line 11
def get_fault_class_ancestors( defined, debug = false)
bool_the_same = false
ancestors = fault_ancestors
if ancestors.blank?
defined << fault_ancestor_hash(get_fault_model_structure, [])
else
defined << fault_ancestor_hash(fault_without_inheritable_elements(ancestors), ancestors)
ancestors[0].get_fault_class_ancestors( defined)
end
ancestors unless bool_the_same
end
|
#get_fault_model_structure ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/washout_builder/document/exception_model.rb', line 69
def get_fault_model_structure
h = {}
get_fault_attributes.each do |method_name|
method_name = method_name.to_s.end_with?("=") ? method_name.to_s.gsub("=", '') : method_name
primitive_type = get_fault_type_method(method_name)
h["#{method_name}"]= {
:primitive => "#{primitive_type}",
:member_type => nil
}
end
return h
end
|
#get_fault_type_method(method_name) ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/washout_builder/document/exception_model.rb', line 57
def get_fault_type_method(method_name)
case method_name.to_s.downcase
when "code"
"integer"
when "message", "backtrace"
"string"
else
"string"
end
end
|
#remove_fault_type_inheritable_elements(keys) ⇒ Object
36
37
38
|
# File 'lib/washout_builder/document/exception_model.rb', line 36
def remove_fault_type_inheritable_elements( keys)
get_fault_model_structure.delete_if{|key,value| keys.include?(key) }
end
|