Sha256: ad1818075d778eca2164c6071d537b05a59725570e81b219e823c44408b48293

Contents?: true

Size: 854 Bytes

Versions: 9

Compression:

Stored size: 854 Bytes

Contents

module Plivo
  module Base
    ##
    # A class to provide a blanket response based on what is
    # being received from Plivo servers.
    #
    # This will be used only during POST and DELETE requests.
    class Response
      ##
      # Instantiating a new instance requires a response_hash
      # The id_symbol should contain a Symbol that represents
      # the identifier of the resource for which this response
      # is being generated for.

      def initialize(response_hash, id_symbol = nil)
        return unless response_hash

        response_hash.each do |k, v|
          instance_variable_set("@#{k}", v)
          self.class.send(:attr_reader, k)
        end
        return unless id_symbol && response_hash.key?(id_symbol)

        self.class.send(:attr_reader, :id)
        @id = response_hash[id_symbol]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
plivo-4.1.6 lib/plivo/base/response.rb
plivo-4.1.5 lib/plivo/base/response.rb
plivo-4.1.4 lib/plivo/base/response.rb
plivo-4.1.3 lib/plivo/base/response.rb
plivo-4.1.2 lib/plivo/base/response.rb
plivo-4.1.1 lib/plivo/base/response.rb
plivo-4.1.0 lib/plivo/base/response.rb
plivo-4.0.0 lib/plivo/base/response.rb
plivo-4.0.0.beta.2 lib/plivo/base/response.rb