Class: OAI::Provider::Response::RecordResponse

Inherits:
Base
  • Object
show all
Defined in:
lib/oai/provider/response/record_response.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #provider

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

default_parameters, #initialize, required_parameters, #response, valid_parameters

Constructor Details

This class inherits a constructor from OAI::Provider::Response::Base

Class Method Details

.inherited(klass) ⇒ Object



3
4
5
6
7
# File 'lib/oai/provider/response/record_response.rb', line 3

def self.inherited(klass)
  klass.valid_parameters    :metadata_prefix, :from, :until, :set
  klass.default_parameters  :from => Proc.new {|x| Time.parse(x.provider.model.earliest.to_s) },
        :until => Proc.new {|x| Time.parse(x.provider.model.latest.to_s) }
end

Instance Method Details

#data_for(record) ⇒ Object

metadata - core routine for delivering metadata records



23
24
25
26
27
# File 'lib/oai/provider/response/record_response.rb', line 23

def data_for(record)
  @builder. do
    @builder.target! << provider.format(requested_format).encode(provider.model, record)
  end
end

#header_for(record) ⇒ Object

emit record header



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/oai/provider/response/record_response.rb', line 10

def header_for(record)
  param = Hash.new
  param[:status] = 'deleted' if deleted?(record)
  @builder.header param do 
    @builder.identifier identifier_for(record)
    @builder.datestamp timestamp_for(record)
    sets_for(record).each do |set|
      @builder.setSpec set.spec
    end
  end
end