Sha256: 84f9262c37ab19c0f80b6701ac8a8a52b6d05d771639ff7335308034278c5ffd

Contents?: true

Size: 803 Bytes

Versions: 39

Compression:

Stored size: 803 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_one(context, "#{self.resource_path}")
        body = body_root(r)
        if body == nil || body.empty?
          Arrest::logger.info "DocumentNotFoundError for #{self.resource_path}"
          raise Errors::DocumentNotFoundError.new
        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

39 entries across 39 versions & 1 rubygems

Version Path
arrest-0.0.74 lib/arrest/single_resource.rb
arrest-0.0.73 lib/arrest/single_resource.rb
arrest-0.0.72 lib/arrest/single_resource.rb
arrest-0.0.71 lib/arrest/single_resource.rb
arrest-0.0.70 lib/arrest/single_resource.rb
arrest-0.0.69 lib/arrest/single_resource.rb
arrest-0.0.68 lib/arrest/single_resource.rb
arrest-0.0.67 lib/arrest/single_resource.rb
arrest-0.0.66 lib/arrest/single_resource.rb
arrest-0.0.65 lib/arrest/single_resource.rb
arrest-0.0.64 lib/arrest/single_resource.rb
arrest-0.0.63 lib/arrest/single_resource.rb
arrest-0.0.62 lib/arrest/single_resource.rb
arrest-0.0.61 lib/arrest/single_resource.rb
arrest-0.0.60 lib/arrest/single_resource.rb
arrest-0.0.59 lib/arrest/single_resource.rb
arrest-0.0.58 lib/arrest/single_resource.rb
arrest-0.0.57 lib/arrest/single_resource.rb
arrest-0.0.56 lib/arrest/single_resource.rb
arrest-0.0.54 lib/arrest/single_resource.rb