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)


48
49
50
# File 'app/models/concerns/shared/loanable.rb', line 48

def has_been_loaned?
  times_loaned > 0
end

#is_loanable?Boolean

Returns True whether this object has this concern, NOT whether it is currently in possesion to be loaned out.

Returns:

  • (Boolean)

    True whether this object has this concern, NOT whether it is currently in possesion to be loaned out



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

def is_loanable?
  true
end

#loan_return_dateObject



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

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)


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

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

#times_loanedObject



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

def times_loaned
  loans.count
end