Sha256: 461de77c111d5c647b73aba6db57d9f679ea62199aba61a0c0729b8f50974823

Contents?: true

Size: 1.97 KB

Versions: 9

Compression:

Stored size: 1.97 KB

Contents

Savon::Model
============

Model for SOAP service oriented applications.

[Bugs](http://github.com/rubiii/savon_model/issues) | [Docs](http://rubydoc.info/gems/savon_model/frames)

Installation
------------

The gem is available through [Rubygems](http://rubygems.org/gems/savon_model) and can be installed via:

    $ gem install savon_model

Getting started
---------------

    class User
      include Savon::Model

      client do                                               [1]
        http.headers["Pragma"] = "no-cache"
      end

      endpoint "http://example.com/users"                     [2]
      namespace "http://v1.example.com/users"                 [3]

      actions :get_user, :get_all_users                       [4]

      def self.all
        get_all_users.to_array                                [5]
      end

      def self.find(id)
        get_user(:id => id).to_hash                           [6]
      end

      def self.delete(id)
        client.request(:delete_user) do                       [7]
          soap.body = { :id => 1 }
        end.to_hash
      end
    end

1. You can call the `client` method with a block of settings to be passed to `Savon::Client.new`.
   The `client` method memoizes a `Savon::Client` instance, so you need to call this method before
   it gets called by any other method.

2. Sets the SOAP endpoint.

3. Sets the SOAP namespace.

4. Specifies the SOAP actions provided by the service. This method dynamically creates both class
   and instance methods named after the arguments. These methods accept an optional SOAP body Hash
   or XML String to be passed to the `Savon::Client` instance.

5. `User.all` calls the `get_all_users` SOAP action and returns a `Savon::Response`.

6. `User.find` calls the `get_user` SOAP action with a SOAP body Hash and returns a `Savon::Response`.

7. This is an example of what happens "behind the scenes" on [6]. You can always use the `client`
   method to directly access and use the `Savon::Client` instance.

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
savon_model-0.4.2 README.md
savon_model-0.4.1 README.md
savon_model-0.4.0 README.md
savon_model-0.3.1 README.md
savon_model-0.3.0 README.md
savon_model-0.2.0 README.md
savon_model-0.1.2 README.md
savon_model-0.1.1 README.md
savon_model-0.1.0 README.md