Sha256: cfd5efdd18768b526b67e0b694a0ea70b5d4be93c06edeb8f2f119c58430e2aa

Contents?: true

Size: 893 Bytes

Versions: 11

Compression:

Stored size: 893 Bytes

Contents

module APIClientBase
  module Response

    def self.module(opts={})
      mod = Module.new do
        mattr_accessor :api_client_base_response_options

        def self.included(base)
          base.class_attribute :api_client_base_response_options
          base.api_client_base_response_options =
            self.api_client_base_response_options
          base.send :include, APIClientBase::Response
        end
      end

      mod.api_client_base_response_options = opts

      mod
    end

    extend ActiveSupport::Concern

    included do
      include Virtus.model
      attribute :raw_response, Object
      attribute :success, self::Boolean, lazy: true, default: :default_success
      attribute :code, Integer, lazy: true, default: :default_code
    end

    def default_success
      raw_response.success?
    end

    def default_code
      raw_response.code
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
api_client_base-1.6.0 lib/api_client_base/response.rb
api_client_base-1.5.0 lib/api_client_base/response.rb
api_client_base-1.4.1 lib/api_client_base/response.rb
api_client_base-1.4.0 lib/api_client_base/response.rb
api_client_base-1.3.0 lib/api_client_base/response.rb
api_client_base-1.2.0 lib/api_client_base/response.rb
api_client_base-1.1.0 lib/api_client_base/response.rb
api_client_base-1.0.0 lib/api_client_base/response.rb
api_client_base-0.2.1 lib/api_client_base/response.rb
api_client_base-0.2.0 lib/api_client_base/response.rb
api_client_base-0.1.0 lib/api_client_base/response.rb