Class: Accountability::Coupon
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Accountability::Coupon
- Defined in:
- app/models/accountability/coupon.rb
Overview
rubocop:disable Rails/HasAndBelongsToMany
Instance Method Summary collapse
- #active? ⇒ Boolean
- #expired? ⇒ Boolean
- #terminated? ⇒ Boolean
- #usable? ⇒ Boolean
- #used_up? ⇒ Boolean
Methods inherited from ApplicationRecord
Instance Method Details
#active? ⇒ Boolean
16 17 18 19 20 21 |
# File 'app/models/accountability/coupon.rb', line 16 def active? return false if activation_date.blank? return false if expired? activation_date.past? end |
#expired? ⇒ Boolean
23 24 25 26 27 28 |
# File 'app/models/accountability/coupon.rb', line 23 def expired? return false if expiration_date.blank? return false if terminated? expiration_date.past? end |
#terminated? ⇒ Boolean
30 31 32 33 34 |
# File 'app/models/accountability/coupon.rb', line 30 def terminated? return false if termination_date.blank? termination_date.past? end |
#usable? ⇒ Boolean
10 11 12 13 14 |
# File 'app/models/accountability/coupon.rb', line 10 def usable? return false if used_up? active? end |
#used_up? ⇒ Boolean
36 37 38 39 40 |
# File 'app/models/accountability/coupon.rb', line 36 def used_up? return false if limit.nil? discounts.count >= limit end |