Sha256: b1675bd36ffce177e5228992eef4bc58cb980c120280ea3932e727413a81fd16

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module SteelWheel
  # Base class for responses
  class Response
    attr_accessor :status

    include ActiveModel::Validations

    unless defined?(ActiveModel::Error)
      def self.generic_validation_keys(*keys)
        include SteelWheel::SkipActiveModelErrorsKeys[*keys]
      end

      generic_validation_keys(:not_found, :forbidden, :unprocessable_entity, :bad_request, :unauthorized)
    end

    def self.name
      'SteelWheel::Response'
    end

    def initialize
      @status = :ok
    end

    def success?
      errors.empty?
    end

    def valid?
      success?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
steel_wheel-0.6.1 lib/steel_wheel/response.rb
steel_wheel-0.6.0 lib/steel_wheel/response.rb