Class: Exlibris::Primo::WebService::Request::Base

Inherits:
Object
  • Object
show all
Includes:
Abstract, Config::Attributes, Namespaces, Client, BaseElements, Call, SoapAction, Exlibris::Primo::WriteAttributes, XmlUtil
Defined in:
lib/exlibris/primo/web_service/request/base.rb

Overview

Abstract base class for Primo interactions

Direct Known Subclasses

Record, Search, UserBase

Constant Summary collapse

DEFAULT_WRAPPER =
:request

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlUtil

included, #to_hash, #to_json

Methods included from Exlibris::Primo::WriteAttributes

#write_attributes

Methods included from SoapAction

included

Methods included from Namespaces

included

Methods included from Config::Attributes

#availability_statuses, #base_url, #config, #facet_collections, #facet_labels, #facet_resource_types, #facet_top_level, #institution, #institutions, #libraries, #sources

Methods included from Call

#call

Methods included from BaseElements

included, #method_missing, #respond_to?

Methods included from Abstract

included

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.


27
28
29
30
31
# File 'lib/exlibris/primo/web_service/request/base.rb', line 27

def initialize *args
  super
  @root = "#{self.class.name.demodulize}Request".camelize(:lower).to_sym
  @wrapper = DEFAULT_WRAPPER.id2name.camelize(:lower).to_sym
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Exlibris::Primo::WebService::Request::BaseElements

Instance Attribute Details

#base_url=(value) ⇒ Object (writeonly)

Sets the attribute base_url

Parameters:

  • value

    the value to set the attribute base_url to.


25
26
27
# File 'lib/exlibris/primo/web_service/request/base.rb', line 25

def base_url=(value)
  @base_url = value
end

#institution=(value) ⇒ Object (writeonly)

Sets the attribute institution

Parameters:

  • value

    the value to set the attribute institution to.


25
26
27
# File 'lib/exlibris/primo/web_service/request/base.rb', line 25

def institution=(value)
  @institution = value
end

Instance Method Details

#to_xml(&block) ⇒ Object


33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/exlibris/primo/web_service/request/base.rb', line 33

def to_xml &block
  namespaces = request_namespaces
  build_xml { |xml|
    xml.send(wrapper) {
      xml.cdata build_xml { |xml|
        xml.send(root, namespaces) {
          yield xml if block
          xml << base_elements_xml
        }
      }
    }
  }
end