Class: Exlibris::Aleph::API::Client::Base
- Inherits:
-
Object
- Object
- Exlibris::Aleph::API::Client::Base
show all
- Defined in:
- lib/exlibris/aleph/api/client/base.rb
Direct Known Subclasses
Patron, Patron::Address, Patron::Record, Patron::Record::Item, Patron::Record::Item::Hold, Patron::Status, Record, Record::Filters, Record::Holding, Record::Holdings, Record::Item, Record::Items
Constant Summary
collapse
- DEFAULT_REQUEST_METHOD =
:get
- VALID_VIEWS =
['full', 'brief']
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(query = {}) ⇒ Base
Returns a new instance of Base.
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 15
def initialize(query={})
unless query.is_a?(Hash)
raise ArgumentError.new("Expecting #{query} to be a Hash")
end
view = query[:view]
unless view.nil? || VALID_VIEWS.include?(view)
raise ArgumentError.new("Expecting #{view} to be one of #{VALID_VIEWS.join(', ')}")
end
@query ||= query.map { |key, value| "#{key}=#{value}"}.join('&')
end
|
Instance Attribute Details
#query ⇒ Object
Returns the value of attribute query.
13
14
15
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 13
def query
@query
end
|
Instance Method Details
#error? ⇒ Boolean
26
27
28
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 26
def error?
reply_code != '0000'
end
|
#reply_code ⇒ Object
30
31
32
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 30
def reply_code
@reply_code ||= root['reply_code']
end
|
#reply_text ⇒ Object
34
35
36
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 34
def reply_text
@reply_text ||= root['reply_text']
end
|
#root ⇒ Object
38
39
40
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 38
def root
@root ||= to_h[root_key]
end
|
#to_h ⇒ Object
42
43
44
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 42
def to_h
@hash ||= MultiXml.parse(to_xml)
end
|
#to_xml ⇒ Object
46
47
48
|
# File 'lib/exlibris/aleph/api/client/base.rb', line 46
def to_xml
@xml ||= body.to_s
end
|