Module: Shared::Loanable

Extended by:
ActiveSupport::Concern
Included in:
CollectionObject, Container, Otu
Defined in:
app/models/concerns/shared/loanable.rb

Overview

Shared code for data classes that can be loaned (used in LoanItem).

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) has_been_loaned?

Returns:

  • (Boolean)


29
30
31
# File 'app/models/concerns/shared/loanable.rb', line 29

def has_been_loaned?
  times_loaned > 0
end

- (Object) loan_return_date



21
22
23
# File 'app/models/concerns/shared/loanable.rb', line 21

def loan_return_date
  loan_item.try(:loan).try(:date_return_expected) ? loan_item.loan.date_return_expected : false
end

- (Boolean) on_loan?

Returns:

  • (Boolean)


17
18
19
# File 'app/models/concerns/shared/loanable.rb', line 17

def on_loan?
  !loan_item.blank? && !loan_item.returned?
end

- (Object) times_loaned



25
26
27
# File 'app/models/concerns/shared/loanable.rb', line 25

def times_loaned 
  loans.count 
end