Sha256: 1115de6a765a117d877408a4ce7a50f77fafab119873123816fcd3e7570a6dfd

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

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

            attr_reader :hold_request, :short_loan, :ill, :booking_request,
              :acquisition_request

            def initialize(root)
              super(root)
              @hold_request = privilege_for_type('HoldRequest')
              @short_loan = privilege_for_type('ShortLoan')
              @ill = privilege_for_type('ILL')
              @booking_request = privilege_for_type('BookingRequest')
              @acquisition_request = privilege_for_type('AcquisitionRequest')
            end

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

            def info
              @info ||= record['info']
            end

            def privilege_for_type(type)
              privilege = info.find { |element| element['type'] == type }
              privilege['allowed'] if privilege
            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.rb
exlibris-aleph-2.0.3 lib/exlibris/aleph/api/reader/patron/record.rb
exlibris-aleph-2.0.0 lib/exlibris/aleph/api/reader/patron/record.rb