Class: Exlibris::Primo::Holding
- Inherits:
-
Object
- Object
- Exlibris::Primo::Holding
- 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 - holdings based on information from the source
default: [self]
Examples
An examples of a customized source is:
-
Exlibris::Primo::Source::Aleph
Direct Known Subclasses
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#availability_status_code ⇒ Object
(also: #status_code)
Returns the value of attribute availability_status_code.
-
#availlibrary ⇒ Object
Returns the value of attribute availlibrary.
-
#call_number ⇒ Object
Returns the value of attribute call_number.
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#display_type ⇒ Object
Returns the value of attribute display_type.
-
#ils_api_id ⇒ Object
Returns the value of attribute ils_api_id.
-
#institution_code ⇒ Object
Returns the value of attribute institution_code.
-
#library_code ⇒ Object
Returns the value of attribute library_code.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#original_id ⇒ Object
Returns the value of attribute original_id.
-
#original_source_id ⇒ Object
Returns the value of attribute original_source_id.
-
#record_id ⇒ Object
Returns the value of attribute record_id.
-
#source_class ⇒ Object
Get the class name from the Primo source config, if not already set.
-
#source_data ⇒ Object
Returns the value of attribute source_data.
-
#source_id ⇒ Object
Returns the value of attribute source_id.
-
#source_record_id ⇒ Object
Returns the value of attribute source_record_id.
-
#subfields ⇒ Object
Returns the value of attribute subfields.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.defaults ⇒ Object
Default values for the class.
Instance Method Summary collapse
-
#availability_status ⇒ Object
(also: #availability, #status)
Get the availability status from the Primo config based on availability status code, if not already set.
-
#expand ⇒ Object
Returns an array of self.
-
#initialize(attributes = {}) ⇒ Holding
constructor
Initialize with a set of attributes and/or another :holding.
-
#institution ⇒ Object
Get the institution from the Primo config based on institution code, if not already set.
-
#library ⇒ Object
Get the library from the Primo config based on library code, if not already set.
-
#merge!(holding) ⇒ Object
Returns self merged with the holding.
-
#source_config ⇒ Object
Get the source config from the Primo config, based on source_id, if not already set.
-
#to_h ⇒ Object
Return the attribute accessible instance variables as a hash.
-
#to_source ⇒ Object
Return this holding as a new holdings subclass instance based on source.
Methods included from WriteAttributes
Methods included from Config::Attributes
#availability_statuses, #base_url, #config, #facet_collections, #facet_labels, #facet_resource_types, #facet_top_level, #institutions, #libraries, #proxy_url, #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
#author ⇒ Object
Returns the value of attribute author.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def end |
#availability_status_code ⇒ Object 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 |
#availlibrary ⇒ Object
Returns the value of attribute availlibrary.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def availlibrary @availlibrary end |
#call_number ⇒ Object
Returns the value of attribute call_number.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def call_number @call_number end |
#collection ⇒ Object
Returns the value of attribute collection.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def collection @collection end |
#coverage ⇒ Object
Returns the value of attribute coverage.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def coverage @coverage end |
#display_type ⇒ Object
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_id ⇒ Object
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_code ⇒ Object
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_code ⇒ Object
Returns the value of attribute library_code.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def library_code @library_code end |
#notes ⇒ Object
Returns the value of attribute notes.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def notes @notes end |
#original_id ⇒ Object
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_id ⇒ Object
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_id ⇒ Object
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_class ⇒ Object
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_data ⇒ Object
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_id ⇒ Object
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_id ⇒ Object
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 |
#subfields ⇒ Object
Returns the value of attribute subfields.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def subfields @subfields end |
#title ⇒ Object
Returns the value of attribute title.
34 35 36 |
# File 'lib/exlibris/primo/holding.rb', line 34 def title @title end |
Class Method Details
.defaults ⇒ Object
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_status ⇒ Object 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 |
#expand ⇒ Object
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 [self] end |
#institution ⇒ Object
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 |
#library ⇒ Object
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_config ⇒ Object
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_h ⇒ Object
Return the attribute accessible instance variables as a hash.
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/exlibris/primo/holding.rb', line 102 def to_h { :availlibrary => availlibrary, :record_id => record_id, :original_id => original_id, :title => title, :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 ⇒ Object
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 |