Sha256: 250fcce82647d9e655190c3c0d02c87a8c4a9e653689584abde9aa3ba0a14bb0

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

module Exlibris
  module Aleph
    class Holding
      attr_reader :record_id, :id
      def initialize(record_id, id)
        @record_id = record_id
        @id = id
      end

      def collection
        unless client.error?
          @collection ||= collections[admin_library].find do |collection|
            collection.code == collection_code &&
              collection.sub_library == sub_library
          end
        end
      end

      def metadata
        @metadata ||= Metadata.new(client.to_xml) unless client.error?
      end

      private
      def client
        @client ||= API::Client::Record::Holding.new(record_id, id)
      end

      def admin_library
        @admin_library ||= sub_library.admin_library
      end

      def sub_library
        @sub_library ||= sub_libraries.find do |sub_library|
          sub_library.code == sub_library_code
        end
      end

      def sub_libraries
        @sub_libraries ||= tables_manager.sub_libraries
      end

      def collections
        @collections ||= tables_manager.collections
      end

      def tables_manager
        @tables_manager ||= TablesManager.instance
      end

      def sub_library_code
        @sub_library_code ||= metadata.sub_location
      end

      def collection_code
        @collection_code ||= metadata.shelving_location
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exlibris-aleph-2.0.4 lib/exlibris/aleph/holding.rb
exlibris-aleph-2.0.3 lib/exlibris/aleph/holding.rb
exlibris-aleph-2.0.0 lib/exlibris/aleph/holding.rb