class Exlibris::Primo::Holding

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:

Attributes

author[RW]
availability_status_code[RW]
availlibrary[RW]
call_number[RW]
collection[RW]
coverage[RW]
display_type[RW]
ils_api_id[RW]
institution_code[RW]
library_code[RW]
notes[RW]
original_id[RW]
original_source_id[RW]
record_id[RW]
source_class[RW]
source_data[RW]
source_id[RW]
source_record_id[RW]
status_code[RW]
status_code=[RW]
subfields[RW]
title[RW]

Public Class Methods

defaults() click to toggle source

Default values for the class.

# File lib/exlibris/primo/holding.rb, line 30
def self.defaults
  @defaults ||= { :coverage => [], :source_data => {} }
end
new(attributes={}) click to toggle source

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

Calls superclass method Exlibris::Primo::WriteAttributes::new
# 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

Public Instance Methods

availability()
Alias for: availability_status
availability_status() click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 75
def availability_status
  @availability_status ||= 
    (availability_statuses[availability_status_code] || availability_status_code)
end
Also aliased as: availability, status
expand() click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 84
def expand
  [self]
end
institution() click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 65
def institution
  @institution ||= (institutions[institution_code] || institution_code)
end
library() click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 70
def library
  @library ||= (libraries[library_code] || library_code)
end
merge!(holding) click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 90
def merge!(holding)
  self
end
source_config() click to toggle source

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

# File lib/exlibris/primo/holding.rb, line 55
def source_config
  @source_config ||= sources[source_id]
end
status()
Alias for: availability_status
to_h() click to toggle source

Return the attribute accessible instance variables as a hash.

# 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_class => source_class, :source_data => source_data }
end
to_source() click to toggle source

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

# 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