Class: OAI::Provider::Response::Base

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

Direct Known Subclasses

Error, Identify, ListSets, RecordResponse

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, options = {}) ⇒ Base

Returns a new instance of Base.



28
29
30
31
32
33
# File 'lib/oai/provider/response.rb', line 28

def initialize(provider, options = {})
  @provider = provider
  @original_options = options.dup
  @options = internalize(options)
  raise OAI::ArgumentException.new unless valid?
end

Class Attribute Details

.default_optionsObject (readonly)

Returns the value of attribute default_options.



10
11
12
# File 'lib/oai/provider/response.rb', line 10

def default_options
  @default_options
end

.required_optionsObject (readonly)

Returns the value of attribute required_options.



10
11
12
# File 'lib/oai/provider/response.rb', line 10

def required_options
  @required_options
end

.valid_optionsObject (readonly)

Returns the value of attribute valid_options.



10
11
12
# File 'lib/oai/provider/response.rb', line 10

def valid_options
  @valid_options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/oai/provider/response.rb', line 7

def options
  @options
end

#providerObject (readonly)

Returns the value of attribute provider.



7
8
9
# File 'lib/oai/provider/response.rb', line 7

def provider
  @provider
end

Class Method Details

.default_parameters(options = {}) ⇒ Object



16
17
18
19
# File 'lib/oai/provider/response.rb', line 16

def default_parameters(options = {})
  @default_options ||= {}
  @default_options.merge! options.dup
end

.required_parameters(*args) ⇒ Object



21
22
23
24
25
# File 'lib/oai/provider/response.rb', line 21

def required_parameters(*args)
  valid_parameters(*args)
  @required_options ||= []
  @required_options = (@required_options + args.dup).uniq
end

.valid_parameters(*args) ⇒ Object



11
12
13
14
# File 'lib/oai/provider/response.rb', line 11

def valid_parameters(*args)
  @valid_options ||= []
  @valid_options = (@valid_options + args.dup).uniq
end

Instance Method Details

#responseObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/oai/provider/response.rb', line 35

def response
  @builder = Builder::XmlMarkup.new
  @builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
  @builder.tag!('OAI-PMH', header) do 
    @builder.responseDate Time.now.utc.xmlschema
    #options parameter has been removed here because with it
    #the data won't validate against oai validators.  Without, it 
    #validates.  
    @builder.request(provider.url) #-- OAI 2.0 Hack - removed request options 
    yield @builder
  end
end