Sha256: d86c7d0df1d56303b1259ae179d2f02b6fbb2899e6d1bfc6d514c146cfcf5f07

Contents?: true

Size: 1.08 KB

Versions: 25

Compression:

Stored size: 1.08 KB

Contents

module SparkApi
  module Models
    module Concerns

      module Destroyable

        def self.included(base)
          base.extend(ClassMethods)
        end

        module ClassMethods

          def destroy(id, arguments = {})
            connection.delete("#{path}/#{id}", arguments)
          end

        end


        def destroy(arguments = {})
          self.errors = []
          begin
            return destroy!(arguments)
          rescue BadResourceRequest => e
            self.errors << {:code => e.code, :message => e.message}
            SparkApi.logger.error("Failed to destroy resource #{self}: #{e.message}")
          rescue NotFound => e
            SparkApi.logger.error("Failed to destroy resource #{self}: #{e.message}")
          end
          false
        end
        def destroy!(arguments = {})
          connection.delete(resource_uri, arguments) if persisted?
          @destroyed = true
          true
        end
        alias_method :delete, :destroy # backwards compatibility

        def destroyed?; @destroyed ? @destroyed : false end

      end

    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
spark_api-1.6.3 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.6.2 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.6.1 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.7 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.6.0 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.6 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.5 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.4 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.3 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.2 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.1 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.5.0 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.34 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.32 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.31 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.29 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.28 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.27 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.26 lib/spark_api/models/concerns/destroyable.rb
spark_api-1.4.25 lib/spark_api/models/concerns/destroyable.rb