Sha256: 1ec7639fb6c63e83490c73e891bd4d0edd84050face89728d4ea3e8e97b74dbc

Contents?: true

Size: 833 Bytes

Versions: 11

Compression:

Stored size: 833 Bytes

Contents

module Arrest
  # A resource that does not maintain a collection of object
  # but a single object.
  class SingleResource < RootResource
    class << self
      def load(context)
        r = source().get(context, "#{self.resource_path}")
        body = body_root(r)
        if body == nil || body.empty?
          Arrest::logger.info "SpecifiedDocumentNotFoundError for #{self.resource_path}"
          raise Errors::SpecifiedDocumentNotFoundError.new(nil, self.class)
        end
        self.build(context, body)
      end

      def find(context, id)
        raise "A find is not possible for a SingleResource"
      end
    end

    # the single resource does not use an id to identify the object
    # since it's already identified by the reource path
    def resource_location
      self.class.resource_path
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
arrest-0.0.91 lib/arrest/single_resource.rb
arrest-0.0.90 lib/arrest/single_resource.rb
arrest-0.0.89 lib/arrest/single_resource.rb
arrest-0.0.88 lib/arrest/single_resource.rb
arrest-0.0.87 lib/arrest/single_resource.rb
arrest-0.0.86 lib/arrest/single_resource.rb
arrest-0.0.85 lib/arrest/single_resource.rb
arrest-0.0.84 lib/arrest/single_resource.rb
arrest-0.0.83.crud lib/arrest/single_resource.rb
arrest-0.0.83.1 lib/arrest/single_resource.rb
arrest-0.0.83 lib/arrest/single_resource.rb