Sha256: a9dfab3b2b6ae1a43dbc6bd40df58dc711c4a34fba04efdb7977c856e29b659b

Contents?: true

Size: 880 Bytes

Versions: 4

Compression:

Stored size: 880 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.delete_if { |m| 
          m =~ /=$/
        }.first
      )
    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.6 lib/sms_notify/soap_response.rb
cdyne-sms-notify-1.0.4 lib/sms_notify/soap_response.rb
cdyne-sms-notify-1.0.3 lib/sms_notify/soap_response.rb
cdyne-sms-notify-1.0.2 lib/sms_notify/soap_response.rb