Sha256: 948905d6950a6ee5c144c94b757a909b6e4e3c7ec99e9024f8820396174a2357

Contents?: true

Size: 457 Bytes

Versions: 19

Compression:

Stored size: 457 Bytes

Contents

module Spyke
  class NormalizedValidationError
    ERROR_KEY = :error

    def initialize(attributes)
      @attributes = attributes
    end

    def message
      case @attributes
      when String
        @attributes
      when Hash
        @attributes[ERROR_KEY].to_sym
      end
    end

    def options
      case @attributes
      when String
        {}
      when Hash
        @attributes.except(ERROR_KEY).symbolize_keys
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
spyke-7.2.2 lib/spyke/normalized_validation_error.rb
spyke-7.1.1 lib/spyke/normalized_validation_error.rb
spyke-7.1.0 lib/spyke/normalized_validation_error.rb
spyke-7.0.0 lib/spyke/normalized_validation_error.rb
spyke-6.1.3 lib/spyke/normalized_validation_error.rb
spyke-6.1.2 lib/spyke/normalized_validation_error.rb
spyke-6.1.1 lib/spyke/normalized_validation_error.rb
spyke-6.1.0 lib/spyke/normalized_validation_error.rb
spyke-6.0.0 lib/spyke/normalized_validation_error.rb
spyke-5.4.3 lib/spyke/normalized_validation_error.rb
spyke-5.4.2 lib/spyke/normalized_validation_error.rb
spyke-5.4.1 lib/spyke/normalized_validation_error.rb
spyke-5.4.0 lib/spyke/normalized_validation_error.rb
spyke-5.3.4 lib/spyke/normalized_validation_error.rb
spyke-5.3.3 lib/spyke/normalized_validation_error.rb
spyke-5.3.2 lib/spyke/normalized_validation_error.rb
spyke-5.3.1 lib/spyke/normalized_validation_error.rb
spyke-5.3.0 lib/spyke/normalized_validation_error.rb
spyke-5.2.0 lib/spyke/normalized_validation_error.rb