Class: VoucherUser

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/voucher_user.rb

Instance Method Summary collapse

Instance Method Details

#already_required(voucher) ⇒ Object

Parameters:

  • voucher

    instance of Voucher



20
21
22
23
24
25
26
27
# File 'app/models/voucher_user.rb', line 20

def already_required(voucher)
    user = VoucherUser.where({voucher_id: voucher[:id], id: @attributes['id']}).first
    if user
        true
    else
        false
    end
end

#confirmObject



13
14
15
16
17
# File 'app/models/voucher_user.rb', line 13

def confirm
    @confirmed = true
    @confirmation_date = Time.now
    @save
end

#has_confirmed(voucher) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/models/voucher_user.rb', line 29

def has_confirmed(voucher)
    user = VoucherUser.where({voucher_id: voucher[:id], id: @attributes['id'], confirmed: true}).first
    if user
        true
    else
        false
    end
end

#send_confirmation_emailObject



38
39
40
# File 'app/models/voucher_user.rb', line 38

def send_confirmation_email
    VoucherMailer.send_confirmation_link(self).deliver
end