Class: Accountability::Coupon
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Accountability::Coupon
- Defined in:
- app/models/accountability/coupon.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
- #expired? ⇒ Boolean
- #terminated? ⇒ Boolean
- #usable? ⇒ Boolean
- #used_up? ⇒ Boolean
Instance Method Details
#active? ⇒ Boolean
14 15 16 17 18 19 |
# File 'app/models/accountability/coupon.rb', line 14 def active? return false if activation_date.blank? return false if expired? activation_date.past? end |
#expired? ⇒ Boolean
21 22 23 24 25 26 |
# File 'app/models/accountability/coupon.rb', line 21 def expired? return false if expiration_date.blank? return false if terminated? expiration_date.past? end |
#terminated? ⇒ Boolean
28 29 30 31 32 |
# File 'app/models/accountability/coupon.rb', line 28 def terminated? return false if termination_date.blank? termination_date.past? end |
#usable? ⇒ Boolean
8 9 10 11 12 |
# File 'app/models/accountability/coupon.rb', line 8 def usable? return false if used_up? active? end |
#used_up? ⇒ Boolean
34 35 36 37 38 |
# File 'app/models/accountability/coupon.rb', line 34 def used_up? return false if limit.nil? discounts.count >= limit end |