Class: OAI::Provider::Model
- Inherits:
-
Object
- Object
- OAI::Provider::Model
- Defined in:
- lib/oai/provider/model.rb
Overview
OAI::Provider::Model
Model implementers should subclass OAI::Provider::Model and override Model#earliest, Model#latest, and Model#find. Optionally Model#sets and Model#deleted? can be used to support sets and record deletions. It is also the responsibility of the model implementer to account for resumption tokens if support is required. Models that don’t support resumption tokens should raise an exception if a limit is requested
during initialization.
earliest - should return the earliest update time in the repository. latest - should return the most recent update time in the repository. sets - should return an array of sets supported by the repository. deleted? - individual records returned should respond true or false when sent the deleted? message. available_formats - if overridden, individual records should return an array of prefixes for all formats in which that record is available, if other than [“oai_dc”]
Resumption Tokens
For examples of using resumption tokens see the ActiveRecordWrapper, and ActiveRecordCachingWrapper classes.
There are several helper models for dealing with resumption tokens please see the ResumptionToken class for more details.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#timestamp_field ⇒ Object
readonly
Returns the value of attribute timestamp_field.
Instance Method Summary collapse
- #deleted? ⇒ Boolean
-
#earliest ⇒ Object
should return the earliest timestamp available from this model.
-
#find(selector, options = {}) ⇒ Object
find is the core method of a model, it returns records from the model bases on the parameters passed in.
-
#initialize(limit = nil, timestamp_field = 'updated_at') ⇒ Model
constructor
A new instance of Model.
-
#last_id(conditions) ⇒ Object
Should return the last id of this model.
-
#latest ⇒ Object
should return the latest timestamp available from this model.
- #sets ⇒ Object
Constructor Details
#initialize(limit = nil, timestamp_field = 'updated_at') ⇒ Model
Returns a new instance of Model.
33 34 35 36 |
# File 'lib/oai/provider/model.rb', line 33 def initialize(limit = nil, = 'updated_at') @limit = limit @timestamp_field = end |
Instance Attribute Details
#timestamp_field ⇒ Object (readonly)
Returns the value of attribute timestamp_field.
31 32 33 |
# File 'lib/oai/provider/model.rb', line 31 def @timestamp_field end |
Instance Method Details
#deleted? ⇒ Boolean
73 74 75 |
# File 'lib/oai/provider/model.rb', line 73 def deleted? false end |
#earliest ⇒ Object
should return the earliest timestamp available from this model.
39 40 41 |
# File 'lib/oai/provider/model.rb', line 39 def earliest raise NotImplementedError.new end |
#find(selector, options = {}) ⇒ Object
find is the core method of a model, it returns records from the model bases on the parameters passed in.
selector
can be a singular id, or the symbol :all options
is a hash of options to be used to constrain the query.
Valid options:
-
:from => earliest timestamp to be included in the results
-
:until => latest timestamp to be included in the results
-
:set => the set from which to retrieve the results
-
:metadata_prefix => type of metadata requested (this may be useful if
not all records are available in all formats)
69 70 71 |
# File 'lib/oai/provider/model.rb', line 69 def find(selector, ={}) raise NotImplementedError.new end |
#last_id(conditions) ⇒ Object
Should return the last id of this model
49 50 51 |
# File 'lib/oai/provider/model.rb', line 49 def last_id(conditions) raise NotImplementedError.new end |
#latest ⇒ Object
should return the latest timestamp available from this model.
44 45 46 |
# File 'lib/oai/provider/model.rb', line 44 def latest raise NotImplementedError.new end |
#sets ⇒ Object
53 54 55 |
# File 'lib/oai/provider/model.rb', line 53 def sets nil end |