Skip to content

Commit f95f80c

Browse files
authored
Merge pull request #71 from code4lib/more_docs
Assorted doc improvements, mostly to ActiveRecordWrapper
2 parents c0caea3 + b6bcc2b commit f95f80c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lib/oai/provider.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
# repository_url 'http://localhost/provider'
5959
# record_prefix 'oai:localhost'
6060
# admin_email 'root@localhost'
61-
# sample_identifier 'oai:pubmedcentral.gov:13900'
61+
# # record_prefix will be automatically prepended to sample_id, so in this
62+
# # case it becomes: oai:localhost:13900
63+
# sample_id '13900'
6264
# source_model MyModel.new
6365
# end
6466
# ```
@@ -107,7 +109,7 @@
107109
# record_prefix 'oai:blog'
108110
# admin_email 'root@localhost'
109111
# source_model OAI::Provider::ActiveRecordWrapper.new(Post)
110-
# sample_identifier 'oai:pubmedcentral.gov:13900'
112+
# sample_id '13900' # record prefix used, so becomes oai:blog:13900
111113
# end
112114
# ```
113115
#
@@ -116,15 +118,25 @@
116118
# ```ruby
117119
# class OaiController < ApplicationController
118120
# def index
119-
# # Remove controller and action from the options. Rails adds them automatically.
120-
# options = params.delete_if { |k,v| %w{controller action}.include?(k) }
121121
# provider = BlogProvider.new
122-
# response = provider.process_request(options)
123-
# render :text => response, :content_type => 'text/xml'
122+
# response = provider.process_request(oai_params.to_h)
123+
# render :body => response, :content_type => 'text/xml'
124+
# end
125+
#
126+
# private
127+
#
128+
# def oai_params
129+
# params.permit(:verb, :identifier, :metadataPrefix, :set, :from, :until, :resumptionToken)
124130
# end
125131
# end
126132
# ```
127133
#
134+
# And route to it in your `config/routes.rb` file:
135+
#
136+
# ```ruby
137+
# match 'oai', to: "oai#index", via: [:get, :post]
138+
# ```
139+
#
128140
# Special thanks to Jose Hales-Garcia for this solution.
129141
#
130142
# ## Supporting custom metadata formats

0 commit comments

Comments
 (0)