class Exlibris::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
Public Class Methods
Default values for the class.
# File lib/exlibris/primo/holding.rb, line 30 def self.defaults @defaults ||= { :coverage => [], :source_data => {} } end
Initialize with a set of attributes and/or another :holding.
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
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
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
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
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
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
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
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