Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 11, 2013
1 parent 672b443 commit 47f020b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
25 changes: 6 additions & 19 deletions app/helpers/washout_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,19 @@ def remove_fault_type_inheritable_elements(param, keys)
end


def same_fault_structure_as_ancestor?(param, ancestor)
param_structure = get_virtus_model_structure(param)
ancestor_structure = get_virtus_model_structure(ancestor)
if param_structure.keys == ancestor_structure.keys
return true, get_virtus_model_structure(param)
else
return false, remove_fault_type_inheritable_elements(param, ancestor_structure.keys)
end
end





def get_fault_class_ancestors(fault, defined)

def get_fault_class_ancestors(fault, defined, debug = false)
bool_the_same = false
unless fault.nil?
ancestors = (fault.ancestors - fault.included_modules).delete_if{ |x| x.to_s.downcase == fault.to_s.downcase || x.to_s == "ActiveRecord::Base" || x.to_s == "Object" || x.to_s =="BasicObject" || x.to_s == "Exception" }
if ancestors.blank?
defined << {:fault => fault,:structure =>get_virtus_model_structure(fault) ,:ancestors => [] }
else
bool_the_same, fault_structure = same_fault_structure_as_ancestor?(fault, ancestors[0])
unless bool_the_same
defined << {:fault => fault,:structure =>fault_structure ,:ancestors => ancestors }
get_fault_class_ancestors(ancestors[0], defined)
end
fault_structure = remove_fault_type_inheritable_elements(fault, get_virtus_model_structure(ancestors[0]).keys)
defined << {:fault => fault,:structure =>fault_structure ,:ancestors => ancestors }
get_fault_class_ancestors(ancestors[0], defined)
end
ancestors unless bool_the_same
end
Expand All @@ -141,7 +128,7 @@ def get_fault_types(map)
defined = defined.collect {|operation, formats| formats[:raises].is_a?(Array) ? formats[:raises] : [formats[:raises]] }.flatten.select { |x| x.is_a?(Class) && x.ancestors.include?(WashOut::SOAPError) } unless defined.blank?
fault_types = []
defined << WashOut::SOAPError
defined.each{ |item| get_fault_class_ancestors(item, fault_types)} unless defined.blank?
defined.each{ |item| get_fault_class_ancestors(item, fault_types, true)} unless defined.blank?
fault_types = fault_types.sort_by { |hash| hash[:fault].to_s.downcase }.uniq unless fault_types.blank?
complex_types = []
fault_types.each do |hash|
Expand Down
2 changes: 1 addition & 1 deletion lib/washout_builder/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module WashoutBuilder
VERSION = "0.9.4"
VERSION = "0.9.5"
end

0 comments on commit 47f020b

Please sign in to comment.