Class: Exlibris::Aleph::Table::Item::CirculationPolicies

Inherits:
Base
  • Object
show all
Defined in:
lib/exlibris/aleph/table/item/circulation_policies.rb

Instance Method Summary collapse

Instance Method Details

#allObject



6
7
8
9
10
11
12
13
14
# File 'lib/exlibris/aleph/table/item/circulation_policies.rb', line 6

def all
  @all ||= begin
    Hash[
      admin_libraries.map do |admin_library|
        [admin_library, Reader::ItemCirculationPolicies.new(admin_library).all]
      end
    ]
  end
end

#find_by_identifier(identifier) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/exlibris/aleph/table/item/circulation_policies.rb', line 16

def find_by_identifier(identifier)
  unless identifier.is_a?(Aleph::Item::CirculationPolicy::Identifier)
    raise ArgumentError.new("Expecting #{identifier} to be a CirculationPolicy::Identifier")
  end
  sub_library = identifier.sub_library
  circulation_policy = _find_by_identifier(identifier)
  # Try with a "generic" item status
  if circulation_policy.nil?
    processing_status = identifier.processing_status
    generic_status_identifier =
      Aleph::Item::CirculationPolicy::Identifier.new(generic_status, processing_status, sub_library)
    circulation_policy = _find_by_identifier(generic_status_identifier)
  end
  # Try with a "generic" item processing status
  if circulation_policy.nil?
    status = identifier.status
    generic_processing_status_identifier =
      Aleph::Item::CirculationPolicy::Identifier.new(status, generic_processing_status, sub_library)
    circulation_policy = _find_by_identifier(generic_processing_status_identifier)
  end
  # Try with both a "generic" item status AND a "generic" item processing status
  if circulation_policy.nil?
    generic_identifier =
      Aleph::Item::CirculationPolicy::Identifier.new(generic_status, generic_processing_status, sub_library)
    circulation_policy = _find_by_identifier(generic_identifier)
  end
  circulation_policy
end