Sha256: cb5b2b2aba963d5b54d8895e37999df0c80a3850282a4f0ffb4e9c620f4773fa

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

module Exlibris
  module Primo
    module WebService
      module Client
        module SoapActions
          def self.included(klass)
            klass.class_eval do
              extend ClassAttributes
            end
          end

          module ClassAttributes
            def soap_actions
              @soap_actions ||= []
            end

            def add_soap_actions *actions
              actions.each do |action|
                soap_actions << action unless soap_actions.include? action
              end
            end
            protected :add_soap_actions
          end

          def soap_actions
            @soap_actions ||= self.class.soap_actions #.concat(client.wsdl.soap_actions)
          end
          protected :soap_actions
          
          # 
          # Define methods for SOAP actions. SOAP actions take a single String argument, request_xml,
          # which is set as the body of the SOAP request
          # 
          def method_missing(method, *args, &block)
            if(soap_actions.include? method)
              self.class.send(:define_method, method) { |request_xml|
                client.request(method) { soap.body = request_xml }
              }
              send method, *args, &block
            else
              super
            end
          end

          #
          # Tell users that we respond to SOAP actions.
          #
          def respond_to?(method, include_private=false)
            (soap_actions.include? method) ? true : super
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
exlibris-primo-1.0.10 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.9 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.8 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.7 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.6 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.5 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.4 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.3 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.2 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.1 lib/exlibris/primo/web_service/client/base/soap_actions.rb
exlibris-primo-1.0.0 lib/exlibris/primo/web_service/client/base/soap_actions.rb