Sha256: 4fc3a65d566dc0dfb6488df7f7d4d7c55044b2f86defd5968771ded21adc6d6d
Contents?: true
Size: 958 Bytes
Versions: 2
Compression:
Stored size: 958 Bytes
Contents
# frozen_string_literal: true require "active_support" module Anony class Result FAILED = "failed" DESTROYED = "destroyed" OVERWRITTEN = "overwritten" SKIPPED = "skipped" attr_reader :status, :fields, :error, :record delegate :failed?, :overwritten?, :skipped?, :destroyed?, to: :status def self.failed(error, record) new(FAILED, record: record, error: error) end def self.overwritten(fields, record) new(OVERWRITTEN, record: record, fields: fields) end def self.skipped(record) new(SKIPPED, record: record) end def self.destroyed(record) new(DESTROYED, record: record) end private def initialize(status, record:, fields: [], error: nil) raise ArgumentError, "No error provided" if status == FAILED && error.nil? @status = ActiveSupport::StringInquirer.new(status) @fields = fields @error = error @record = record end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anony-1.6.0 | lib/anony/result.rb |
anony-1.5.0 | lib/anony/result.rb |