Class: Exlibris::Primo::Holding

Inherits:
Object
  • Object
show all
Includes:
Config::Attributes, WriteAttributes
Defined in:
lib/exlibris/primo/holding.rb

Overview

Primo Holding.

Object representing a holding in Primo.

Primo holdings can be extended to create Primo source holdings. create a local class representing the source in the module Exlibris::Primo::Source which extends Exlibris::Primo::Holding. Holding methods are then available for overriding.

A special use case occurs when Primo normalization rules contract record holdings, e.g. in the case of multiple holdings in a single Aleph collection. In these cases, a source holding can “expand” itself and return an Array of holdings.

:expand -   expand holdings based on information from the source
            default: [self]

Examples

An examples of a customized source is:

  • Exlibris::Primo::Source::Aleph

Direct Known Subclasses

Source::Aleph

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WriteAttributes

#write_attributes

Methods included from Config::Attributes

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

Constructor Details

#initialize(attributes = {}) ⇒ Holding

Initialize with a set of attributes and/or another :holding.



45
46
47
48
49
50
51
52
# File 'lib/exlibris/primo/holding.rb', line 45

def initialize(attributes={})
  # Get holding
  holding = attributes.delete(:holding)
  # Instantiate new holding from input holding
  # if it exists.
  super((holding.nil?) ? self.class.defaults.merge(attributes) : 
    holding.to_h.merge(attributes))
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def author
  @author
end

#availability_status_codeObject Also known as: status_code

Returns the value of attribute availability_status_code.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def availability_status_code
  @availability_status_code
end

#availlibraryObject

Returns the value of attribute availlibrary.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def availlibrary
  @availlibrary
end

#call_numberObject

Returns the value of attribute call_number.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def call_number
  @call_number
end

#collectionObject

Returns the value of attribute collection.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def collection
  @collection
end

#coverageObject

Returns the value of attribute coverage.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def coverage
  @coverage
end

#display_typeObject

Returns the value of attribute display_type.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def display_type
  @display_type
end

#ils_api_idObject

Returns the value of attribute ils_api_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def ils_api_id
  @ils_api_id
end

#institution_codeObject

Returns the value of attribute institution_code.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def institution_code
  @institution_code
end

#library_codeObject

Returns the value of attribute library_code.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def library_code
  @library_code
end

#notesObject

Returns the value of attribute notes.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def notes
  @notes
end

#original_idObject

Returns the value of attribute original_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def original_id
  @original_id
end

#original_source_idObject

Returns the value of attribute original_source_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def original_source_id
  @original_source_id
end

#record_idObject

Returns the value of attribute record_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def record_id
  @record_id
end

#source_classObject

Get the class name from the Primo source config, if not already set.



60
61
62
# File 'lib/exlibris/primo/holding.rb', line 60

def source_class
  @source_class
end

#source_dataObject

Returns the value of attribute source_data.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def source_data
  @source_data
end

#source_idObject

Returns the value of attribute source_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def source_id
  @source_id
end

#source_record_idObject

Returns the value of attribute source_record_id.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def source_record_id
  @source_record_id
end

#subfieldsObject

Returns the value of attribute subfields.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def subfields
  @subfields
end

#titleObject

Returns the value of attribute title.



34
35
36
# File 'lib/exlibris/primo/holding.rb', line 34

def title
  @title
end

Class Method Details

.defaultsObject

Default values for the class.



30
31
32
# File 'lib/exlibris/primo/holding.rb', line 30

def self.defaults
  @defaults ||= { :coverage => [], :source_data => {} }
end

Instance Method Details

#availability_statusObject Also known as: availability, status

Get the availability status from the Primo config based on availability status code, if not already set.



75
76
77
78
# File 'lib/exlibris/primo/holding.rb', line 75

def availability_status
  @availability_status ||= 
    (availability_statuses[availability_status_code] || availability_status_code)
end

#expandObject

Returns an array of self. Should be overridden by source subclasses if appropriate.



84
85
86
# File 'lib/exlibris/primo/holding.rb', line 84

def expand
  [self]
end

#institutionObject

Get the institution from the Primo config based on institution code, if not already set.



65
66
67
# File 'lib/exlibris/primo/holding.rb', line 65

def institution
  @institution ||= (institutions[institution_code] || institution_code)
end

#libraryObject

Get the library from the Primo config based on library code, if not already set.



70
71
72
# File 'lib/exlibris/primo/holding.rb', line 70

def library
  @library ||= (libraries[library_code] || library_code)
end

#merge!(holding) ⇒ Object

Returns self merged with the holding. No actual merging happens in the default implementation.



90
91
92
# File 'lib/exlibris/primo/holding.rb', line 90

def merge!(holding)
  self
end

#source_configObject

Get the source config from the Primo config, based on source_id, if not already set.



55
56
57
# File 'lib/exlibris/primo/holding.rb', line 55

def source_config
  @source_config ||= sources[source_id]
end

#to_hObject

Return the attribute accessible instance variables as a hash.



102
103
104
105
106
107
108
109
110
# File 'lib/exlibris/primo/holding.rb', line 102

def to_h
  { :availlibrary => availlibrary, :record_id => record_id, :original_id => original_id, 
    :title => title, :author => author, :display_type => display_type, :source_id => source_id,
    :original_source_id => original_source_id, :source_record_id => source_record_id,
    :ils_api_id => ils_api_id, :institution_code => institution_code, :library_code => library_code,
    :availability_status_code => availability_status_code, :collection => collection,
    :call_number => call_number, :coverage => coverage, :notes => notes, :subfields => subfields,
    :source_id => source_id, :source_class => source_class, :source_data => source_data }
end

#to_sourceObject

Return this holding as a new holdings subclass instance based on source



95
96
97
98
99
# File 'lib/exlibris/primo/holding.rb', line 95

def to_source
  return self if source_class.nil?
  # Get source class in Primo::Source module
  return Exlibris::Primo::Source.const_get(source_class).new(:holding => self)
end