Sha256: c4d4b0a506b0c411748a280768d962b5c67f9ab70b01fa863dac21db332f7ba4

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

module Exlibris
  module Aleph
    module API
      module Reader
        class Patron < Base
          class Record < Base
            class Item < Base
              class Hold < Base

                attr_reader :allowed

                def initialize(root)
                  super(root)
                  @allowed = hold['allowed']
                end

                def pickup_locations
                  @pickup_locations ||= pickup_location.map do |location|
                    code = location['code']
                    display = location['__content__']
                    PickupLocation.new(code, display)
                  end
                end

                private
                def hold
                  @hold ||= root['hold']
                end

                def pickup_locations_root
                  unless hold.nil?
                    @pickup_locations_root ||= hold['pickup_locations']
                  end
                end

                def pickup_location
                  @pickup_location ||= begin
                    if pickup_locations_root.nil?
                      []
                    elsif pickup_locations_root['pickup_location'].nil?
                      []
                    elsif pickup_locations_root['pickup_location'].is_a?(Hash)
                      [pickup_locations_root['pickup_location']]
                    else
                      pickup_locations_root['pickup_location']
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exlibris-aleph-2.0.4 lib/exlibris/aleph/api/reader/patron/record/item/hold.rb
exlibris-aleph-2.0.3 lib/exlibris/aleph/api/reader/patron/record/item/hold.rb
exlibris-aleph-2.0.0 lib/exlibris/aleph/api/reader/patron/record/item/hold.rb