Class: OAI::Provider::Response::ListRecords
- Inherits:
-
RecordResponse
- Object
- Base
- RecordResponse
- OAI::Provider::Response::ListRecords
- Defined in:
- lib/oai/provider/response/list_records.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from RecordResponse
#about_for, #data_for, default_from, default_until, #header_for, inherited
Methods inherited from Base
default_parameters, #initialize, required_parameters, #response, valid_parameters
Constructor Details
This class inherits a constructor from OAI::Provider::Response::Base
Instance Method Details
#matching_granularity? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/oai/provider/response/list_records.rb', line 10 def matching_granularity? if [:from].nil? == false && [:until].nil? == false && [:from].class.name != [:until].class.name raise OAI::ArgumentException.new, "The 'from' and 'until' options specified must have the same granularity" else true end end |
#to_xml ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oai/provider/response/list_records.rb', line 18 def to_xml result = provider.model.find(:all, ) # result may be an array of records, or a partial result records = result.respond_to?(:records) ? result.records : result raise OAI::NoMatchException.new if records.nil? or records.empty? response do |r| r.ListRecords do records.each do |rec| r.record do header_for rec data_for rec unless deleted?(rec) about_for rec unless deleted?(rec) end end # append resumption token for getting next group of records if result.respond_to?(:token) r.target! << result.token.to_xml end end end end |
#valid? ⇒ Boolean
6 7 8 |
# File 'lib/oai/provider/response/list_records.rb', line 6 def valid? super && matching_granularity? end |