Sha256: 55d87a243a63661f757d120f9cccdf62e76f080613af13df024227641383b67e

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

module RackFakeS3
  class RackFakeS3Exception < RuntimeError
    attr_accessor :resource,:request_id

    def self.metaclass; class << self; self; end; end

    def self.traits(*arr)
      return @traits if arr.empty?
      attr_accessor *arr

      arr.each do |a|
        metaclass.instance_eval do
          define_method( a ) do |val|
            @traits ||= {}
            @traits[a] = val
          end
        end
      end

      class_eval do
        define_method( :initialize ) do
          self.class.traits.each do |k,v|
            instance_variable_set("@#{k}", v)
          end
        end
      end
    end

    traits :message,:http_status

    def code
      self.class.to_s
    end
  end

  class NoSuchBucket < RackFakeS3Exception
    message "The bucket you tried to delete is not empty."
    http_status "404"
  end

  class BucketNotEmpty < RackFakeS3Exception
    message "The bucket you tried to delete is not empty."
    http_status "409"
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rack_fake_s3-0.2.4 lib/rack_fake_s3/errors.rb
rack_fake_s3-0.2.3 lib/rack_fake_s3/errors.rb
rack_fake_s3-0.2.2 lib/rack_fake_s3/errors.rb
rack_fake_s3-0.2.1 lib/rack_fake_s3/errors.rb
rack_fake_s3-0.2.0 lib/rack_fake_s3/errors.rb