Sha256: 53304ea2c44d06cf15a9a8be8f3a042f5469f4b973c960cb78a74906d2ec8644

Contents?: true

Size: 867 Bytes

Versions: 2

Compression:

Stored size: 867 Bytes

Contents

require_relative 'codes'
require_relative 'response'

module Voom
  module Commands
    module SuccessAndFail
      def success(data: [], warnings: {}, snackbar: [])
        SuccessAndFail.success(data: data, warnings: warnings, snackbar: snackbar)
      end

      def fail(status: Commands::Codes::FAILURE, errors: {}, warnings: {}, data: [])
        SuccessAndFail.fail(status: status, errors: errors, warnings: warnings, data: data)
      end

      def self.success(data: [], warnings: {}, snackbar: [])
        Response.new(data: data, status: Commands::Codes::SUCCESS, messages: {errors: {}, warnings: warnings, snackbar: snackbar})
      end

      def self.fail(status: Commands::Codes::FAILURE, errors: {}, warnings: {}, data: [])
        Response.new(data: data, status: status, messages: {errors: errors, warnings: warnings})
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voom-commands-0.1.1 lib/voom/commands/success_and_fail.rb
voom-commands-0.1.0 lib/voom/commands/success_and_fail.rb