Sha256: dea7d36cd8034b2258d4185f50fe508c062852640396963df4d640e85a0280b2

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

module Nuncium
  module Responses
    class Body
      def initialize(response)
        (response.keys - self.class::REMOVED_KEYS).each do |key|
          self.class.send(:attr_accessor, key.to_sym)
          instance_variable_set("@#{key}", parsed_value(response[key]))
        end
      end

      private

      def parsed_value(value)
        return value unless value.is_a?(Hash)
        value.keys.first == 'xsi:nil' && value.values.first == 'true' ? nil : false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nuncium-0.13.0 lib/nuncium/responses/body.rb