Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Dec 2, 2013
1 parent 293ca6c commit 2434b04
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Please read {release details}[https://github.com/bogdanRada/washout_builder/rele
The way soap_actions, or reusable types are defined or how the configuration is made using WashOut(https://github.com/inossidabile/wash_out) haven't changed
You can still do everything that gem does .

When specifying the <b>soap_action</b> you can also pass a <b>option for description</b> and a <b>list of exceptions</b> that the method can raise at a certain moment.
When specifying the <b>soap_action</b> you can also pass a <b>option for description</b> and a <b>list of exceptions(need to be instances as example)</b> that the method can raise at a certain moment.

The exception classes used <b>must inherit</b> from <tt>WashOut::Dispatcher::SOAPError</tt>, which has by default a error code and a message as attributes but you can extend it by adding more accessible_attributes to your own custom class.

<b> If your custom exception class doesn't have any accesible_attributes, these attributes will not appear in the documentation!!!</b>

Here is an example :

soap_action "find", :args => {:number => :integer} , :return => :boolean, :raises => [MyFirstExceptionClass, MySecondExceptionClass ] , :description => "some description about this method to show in the documentation"
soap_action "find", :args => {:number => :integer} , :return => :boolean, :raises => [MyFirstExceptionClass.new(1, "found error"), MySecondExceptionClass(1, "found another error"}) ] , :description => "some description about this method to show in the documentation"


In order to see the documentation you must write something like this in the routes (exactly like you would do when using only WashOut)
Expand Down
41 changes: 22 additions & 19 deletions app/helpers/washout_builder_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_fault_types_names(map)
unless faults.blank?
faults = [formats[:raises]] if !faults.is_a?(Array)
faults.each do |p|
defined << p.to_s.classify
defined << p.class.to_s
end
end
end
Expand Down Expand Up @@ -125,33 +125,36 @@ def create_html_fault_types_details(xml, map)
end
end
unless defined.blank?
defined = defined.sort_by { |name| name.to_s.downcase }.uniq
defined = defined.sort_by { |name| name.class.to_s.downcase }.uniq
defined.each do |fault|
create_html_fault_type(xml, fault)
end
end
end

def create_html_fault_type(xml, param)
if param.ancestors.include?(WashOut::Dispatcher::SOAPError)
xml.h3 "#{param}"
xml.a("name" => "#{param}") {}
xml.ul("class" => "pre") {


param.accessible_attributes.each do |attribute|
xml.li { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(attribute.class.name.downcase) && attribute != "errors"
pre << "<span class='blue'>#{attribute.class.name.downcase}</span>&nbsp;<span class='bold'>#{attribute}</span>"
elsif attribute == "errors"
pre << "<a href='#ValidationErrors'><span class='lightBlue'>Array of ValidationErrors</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
else
pre << "<a href='##{attribute.class.name}'><span class='lightBlue'>#{attribute.class.name}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
end
}
if param.class.ancestors.include?(WashOut::Dispatcher::SOAPError)
xml.h3 "#{param.class}"
xml.a("name" => "#{param.class}") {}
xml.ul("class" => "pre") {


param.class.accessible_attributes.each do |attribute|
if attribute!="code" && attribute != "message" && attribute!= 'backtrace'
attribute_class = param.send(attribute).class.name.downcase
xml.li { |pre|
if WashoutBuilder::Type::BASIC_TYPES.include?(attribute_class) || attribute_class == "nilclass"
pre << "<span class='blue'>#{attribute_class == "nilclass" ? "string" : attribute_class }</span>&nbsp;<span class='bold'>#{attribute}</span>"
else
pre << "<a href='##{attribute.class.name}'><span class='lightBlue'>#{attribute.class.name}</span></a>&nbsp;<span class='bold'>#{attribute}</span>"
end
}
end
end
xml.li { |pre| pre << "<span class='blue'>integer</span>&nbsp;<span class='bold'>code</span>" }
xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<span class='bold'>message</span>" }
xml.li { |pre| pre << "<span class='blue'>string</span>&nbsp;<span class='bold'>backtrace</span>" }
}
}
end
end

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.4.0"
VERSION = "0.4.1"
end

0 comments on commit 2434b04

Please sign in to comment.