Class: Alma::Loan

Inherits:
AlmaRecord show all
Extended by:
ApiDefaults
Defined in:
lib/alma/loan.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApiDefaults

apikey, bibs_base_path, configuration_base_path, headers, items_base_path, region, timeout, users_base_path

Methods inherited from AlmaRecord

#initialize, #method_missing, #post_initialize, #respond_to_missing?, #response

Constructor Details

This class inherits a constructor from Alma::AlmaRecord

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Alma::AlmaRecord

Class Method Details

.where_user(user_id, args = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/alma/loan.rb', line 24

def self.where_user(user_id, args = {})
  # Always expand renewable unless you really don't want to
  args[:expand] ||= "renewable"
  # Default to upper limit
  args[:limit] ||= 100
  response = Net.get(
    "#{users_base_path}/#{user_id}/loans",
    query: args,
    headers:,
    timeout:
    )
  Alma::LoanSet.new(response, args)
end

Instance Method Details

#overdue?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/alma/loan.rb', line 16

def overdue?
  loan_status == "Overdue"
end

#renewObject



20
21
22
# File 'lib/alma/loan.rb', line 20

def renew
  Alma::User.renew_loan({ user_id:, loan_id: })
end

#renewableObject



12
13
14
# File 'lib/alma/loan.rb', line 12

def renewable
  response.fetch("renewable", false)
end

#renewable?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/alma/loan.rb', line 8

def renewable?
  !!renewable
end