Module: LoansHelper

Defined in:
app/helpers/loans_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) loan_history_tag(object)



28
29
30
# File 'app/helpers/loans_helper.rb', line 28

def loan_history_tag(object)
  (:li, "Loaned #{object.times_loaned} times.")
end


8
9
10
11
# File 'app/helpers/loans_helper.rb', line 8

def loan_link(loan)
  return nil if loan.nil?
  link_to(loan_tag(loan).html_safe, loan)
end

- (Object) loan_status_tag(object)



18
19
20
21
22
23
24
25
26
# File 'app/helpers/loans_helper.rb', line 18

def loan_status_tag(object)
  if object.is_loanable? && object.has_been_loaned?
    (:h3, 'Loan status') + 
      (:ul) do
      (on_loan_tag(object) +
       loan_history_tag(object)).html_safe
    end
  end
end

- (Object) loan_tag(loan)



3
4
5
6
# File 'app/helpers/loans_helper.rb', line 3

def loan_tag(loan)
  return nil if loan.nil?
  [loan.id, loan.people.collect{|a| a.name}.join(', '), loan.recipient_address].delete_if{|b| b.blank? }.join(" - ").gsub(/\n/, '; ') 
end

- (Object) loans_search_form



13
14
15
# File 'app/helpers/loans_helper.rb', line 13

def loans_search_form
  render('/loans/quick_search_form')
end

- (Object) on_loan_tag(object)



32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/loans_helper.rb', line 32

def on_loan_tag(object)
  if object.is_loanable? && object.on_loan?
    (:li) do
      ('On ' + 
        link_to('loan', object.loan) + '.' +
        " Due back on #{object.loan_return_date}. #{overdue_tag(object.loan)}").html_safe
    end
  else
    ''
  end
end

- (Object) overdue_tag(loan)



44
45
46
47
48
49
50
# File 'app/helpers/loans_helper.rb', line 44

def overdue_tag(loan)
  if loan.overdue?
    "#{loan.days_overdue} days overdue."
  else
    "#{loan.days_until_due} days until due."  
  end
end