Sha256: 613fb54eeaa92a6e59a44430ac55f7e91b1154a9582018ced7482166cfd98643

Contents?: true

Size: 799 Bytes

Versions: 7

Compression:

Stored size: 799 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 "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

7 entries across 7 versions & 1 rubygems

Version Path
arrest-0.0.82 lib/arrest/single_resource.rb
arrest-0.0.80 lib/arrest/single_resource.rb
arrest-0.0.79 lib/arrest/single_resource.rb
arrest-0.0.78 lib/arrest/single_resource.rb
arrest-0.0.77 lib/arrest/single_resource.rb
arrest-0.0.76 lib/arrest/single_resource.rb
arrest-0.0.75 lib/arrest/single_resource.rb