Sha256: 4b1f3de3b70447f46521bc2a2c3ea4a273df88b1424aace7d05b54228a3f5e8e

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

module SmsNotify
  class SoapResponse
    attr_accessor :soap_response

    # Retrieve the underlying soap object
    # from the wsdl driver.
    def initialize(soap_mapping_object)
      @soap_response = soap_mapping_object.send(
        soap_mapping_object.singleton_methods[0]
      )
    end

    # Convert this objects attributes
    # to ruby like hash.
    def to_hash
      response_hash = {}
      soap_mapping_attributes.each { |attr|
        response_hash.merge!(
          attr.underscore.to_sym => self.soap_response.send(attr)
        )
      }
      response_hash
    end

    # Grab all the getter methods defined for the
    # attributes of the underlying soap response object.
    def soap_mapping_attributes
      self.soap_response.singleton_methods.delete_if { |m|
        m =~ /=$/
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cdyne-sms-notify-1.0.1 lib/sms_notify/soap_response.rb
cdyne-sms-notify-1.0.0 lib/sms_notify/soap_response.rb
cdyne-sms-notify-0.10.1 lib/sms_notify/soap_response.rb
cdyne-sms-notify-0.10.0 lib/sms_notify/soap_response.rb