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

#has_been_loaned?Boolean

Should just be check of loan_items

Returns:

  • (Boolean)


43
44
45
# File 'app/models/concerns/shared/loanable.rb', line 43

def has_been_loaned?
  times_loaned > 0
end

#loan_return_dateObject



34
35
36
# File 'app/models/concerns/shared/loanable.rb', line 34

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

#on_loan?Boolean

Returns:

  • (Boolean)


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

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

#times_loanedObject



38
39
40
# File 'app/models/concerns/shared/loanable.rb', line 38

def times_loaned 
  loans.count 
end