Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map XML arguments (XSD) to ruby class #250

Open
Ramanpreetsingh opened this issue Feb 20, 2018 · 1 comment
Open

Map XML arguments (XSD) to ruby class #250

Ramanpreetsingh opened this issue Feb 20, 2018 · 1 comment

Comments

@Ramanpreetsingh
Copy link

Ramanpreetsingh commented Feb 20, 2018

Going by the sample example:


# Params from XML attributes;
  # e.g. for a request to the 'AddCircle' action:
  #   <soapenv:Envelope>
  #     <soapenv:Body>
  #       <AddCircle>
  #         <Circle radius="5.0">
  #           <Center x="10" y="12" />
  #         </Circle>
  #       </AddCircle>
  #     </soapenv:Body>
  #   </soapenv:Envelope>
  soap_action "AddCircle",
              :args   => { :circle => { :center => { :@x => :integer,
                                                     :@y => :integer },
                                        :@radius => :double } },
              :return => nil, # [] for wash_out below 0.3.0
              :to     => :add_circle
  def add_circle
    circle = params[:circle]
    Circle.new(circle[:center][:x], circle[:center][:y], circle[:radius])

    render :soap => nil
  end

My XML request has many nested arguments and I don't want to define mappings (:args) for each XML attribute. Is there any way to map the XML arguments to ruby class or a more convenient way to do this.

@dub357
Copy link

dub357 commented Sep 27, 2019

I know this is a little late, but can't you do something like the following?

soap_action "AddCircle", :args   => Circle.washout_args

class Circle
  def self.washout_args
     {
       :circle => {
         :center => {
            :@x => :integer,
            :@y => :integer 
         },
         :@radius => :double 
      } 
    }
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants