Sha256: b8f260a45ef05a311e0210053b19d10ba9f02d83c94e111b9b8073bbf806039b

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

require 'wash_out'
require 'virtus'
require 'washout_builder/soap'
require 'washout_builder/engine'
require 'washout_builder/document/complex_type'
require 'washout_builder/document/virtus_model'
require 'washout_builder/document/generator'
require 'washout_builder/dispatcher'
require 'washout_builder/type'
require 'washout_builder/version'


module ActionDispatch::Routing
  class  Mapper

    alias_method  :original_wash_out,:wash_out

    # Adds the routes for a SOAP endpoint at +controller+.
    def wash_out(controller_name, options={})
      options.reverse_merge!(@scope) if @scope

      match "#{controller_name}/doc"   => "#{controller_name}#_generate_doc", :via => :get, :format => false
      original_wash_out(controller_name, options)


    end
  end
end

Virtus::InstanceMethods::Constructor.class_eval do
  alias_method  :original_initialize,:initialize
  def initialize(attributes = nil)
    if  self.class.ancestors.include?(WashOut::SOAPError) || self.is_a?(WashOut::SOAPError)
      attributes = {:message => attributes} unless attributes.is_a?(Hash) 
    end
    original_initialize(attributes)
  end
end


WashOut::Param.send :include, WashoutBuilder::Document::ComplexType

[WashOut::SOAPError, SOAPError].each do |exception_class|
  exception_class.class_eval do
    extend WashoutBuilder::Document::VirtusModel
     include Virtus.model
      attribute :code, Integer
      attribute :message, String
      attribute :backtrace, String
  end
end




ActionController::Base.class_eval do

  # Define a SOAP service. The function has no required +options+:
  # but allow any of :parser, :namespace, :wsdl_style, :snakecase_input,
  # :camelize_wsdl, :wsse_username, :wsse_password and :catch_xml_errors.
  #
  # Any of the the params provided allows for overriding the defaults
  # (like supporting multiple namespaces instead of application wide such)
  #
  def self.soap_service(options={})
    include WashoutBuilder::SOAP
    self.soap_config = options
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
washout_builder-0.10.2 lib/washout_builder.rb
washout_builder-0.10.1 lib/washout_builder.rb