Sha256: 3c300e142ffd6abb0737f29c0f82fe54ff036f7a00264f3f8d3e0208afde8cf2

Contents?: true

Size: 577 Bytes

Versions: 2

Compression:

Stored size: 577 Bytes

Contents

module Tessera
  module Model
    class Base
      attr_accessor :response, :errors, :code

      def initialize(response)
        @response = response
        @code = @response.code
        parse_errors if parsed_body
        parse_attributes if parsed_body
      end

      protected

      def parse_errors
        @errors = parsed_body['Error']
      end

      def parsed_body
        JSON.parse(@response.body) if @response.body
      end

      def parse_attributes
        raise NotImplementedError, 'Model must implement attribute mapping'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tessera-1.0.1 lib/tessera/model/base.rb
tessera-1.0.0 lib/tessera/model/base.rb