11module OAI ::Provider
22 # = OAI::Provider::Model
33 #
4- # Model implementers should subclass OAI::Provider::Model and override
4+ # Model implementers should subclass OAI::Provider::Model and override
55 # Model#earliest, Model#latest, and Model#find. Optionally Model#sets and
6- # Model#deleted? can be used to support sets and record deletions. It
7- # is also the responsibility of the model implementer to account for
8- # resumption tokens if support is required. Models that don't support
9- # resumption tokens should raise an exception if a limit is requested
6+ # Model#deleted? can be used to support sets and record deletions. It
7+ # is also the responsibility of the model implementer to account for
8+ # resumption tokens if support is required. Models that don't support
9+ # resumption tokens should raise an exception if a limit is requested
1010 # during initialization.
1111 #
1212 # earliest - should return the earliest update time in the repository.
1313 # latest - should return the most recent update time in the repository.
1414 # sets - should return an array of sets supported by the repository.
1515 # deleted? - individual records returned should respond true or false
1616 # when sent the deleted? message.
17- # available_formats - if overridden, individual records should return an
18- # array of prefixes for all formats in which that record is available,
17+ # available_formats - if overridden, individual records should return an
18+ # array of prefixes for all formats in which that record is available,
1919 # if other than ["oai_dc"]
2020 # about - if overridden, should return a String or Array of XML Strings to
2121 # insert into the OAI Record <about> chunks.
@@ -28,29 +28,29 @@ module OAI::Provider
2828 # There are several helper models for dealing with resumption tokens please
2929 # see the ResumptionToken class for more details.
3030 #
31-
3231 class Model
33- attr_reader :timestamp_field
34-
35- def initialize ( limit = nil , timestamp_field = 'updated_at' )
32+ attr_reader :timestamp_field , :identifier_field
33+
34+ def initialize ( limit = nil , timestamp_field = 'updated_at' , identifier_field = 'id' )
3635 @limit = limit
36+ @identifier_field = identifier_field
3737 @timestamp_field = timestamp_field
3838 end
3939
4040 # should return the earliest timestamp available from this model.
4141 def earliest
4242 raise NotImplementedError . new
4343 end
44-
44+
4545 # should return the latest timestamp available from this model.
4646 def latest
4747 raise NotImplementedError . new
4848 end
49-
49+
5050 def sets
5151 nil
5252 end
53-
53+
5454 # find is the core method of a model, it returns records from the model
5555 # bases on the parameters passed in.
5656 #
@@ -61,12 +61,12 @@ def sets
6161 # * :from => earliest timestamp to be included in the results
6262 # * :until => latest timestamp to be included in the results
6363 # * :set => the set from which to retrieve the results
64- # * :metadata_prefix => type of metadata requested (this may be useful if
64+ # * :metadata_prefix => type of metadata requested (this may be useful if
6565 # not all records are available in all formats)
6666 def find ( selector , options = { } )
6767 raise NotImplementedError . new
6868 end
69-
69+
7070 def deleted?
7171 false
7272 end
@@ -76,5 +76,5 @@ def about record
7676 nil
7777 end
7878 end
79-
79+
8080end
0 commit comments