Sha256: 248cf842413b0e199c04f9ef544713f9b28af1adffd5c3de11ecd269e6435409

Contents?: true

Size: 961 Bytes

Versions: 135

Compression:

Stored size: 961 Bytes

Contents

module FakeS3
  class FakeS3Exception < 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 < FakeS3Exception
    message "The bucket you tried to delete is not empty."
    http_status "404"
  end

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

end

Version data entries

135 entries across 135 versions & 27 rubygems

Version Path
plntr-fakes3-1.0.0.pre.28 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.27 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.26 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.25 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.24 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.23 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.22 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.21 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.20 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.19 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.18 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.17 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.16 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.15 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.14 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.13 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.12 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.12alpha2 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.12alpha1 lib/fakes3/errors.rb
plntr-fakes3-1.0.0.pre.11 lib/fakes3/errors.rb