Class: Spree::StoreCreditCategory
- Inherits:
-
Object
- Object
- Spree::StoreCreditCategory
- Defined in:
- app/models/spree/store_credit_category.rb
Constant Summary collapse
- GIFT_CARD_CATEGORY_NAME =
'Gift Card'.freeze
- DEFAULT_NON_EXPIRING_TYPES =
[GIFT_CARD_CATEGORY_NAME]
Class Method Summary collapse
Instance Method Summary collapse
- #can_be_deleted? ⇒ Boolean
- #non_expiring? ⇒ Boolean
- #non_expiring_category_types ⇒ Object
- #store_credit_category_used? ⇒ Boolean
- #validate_not_used ⇒ Object
Class Method Details
.default_reimbursement_category(_options = {}) ⇒ Object
38 39 40 |
# File 'app/models/spree/store_credit_category.rb', line 38 def default_reimbursement_category( = {}) Spree::StoreCreditCategory.first end |
Instance Method Details
#can_be_deleted? ⇒ Boolean
33 34 35 |
# File 'app/models/spree/store_credit_category.rb', line 33 def can_be_deleted? !store_credit_category_used? end |
#non_expiring? ⇒ Boolean
14 15 16 |
# File 'app/models/spree/store_credit_category.rb', line 14 def non_expiring? non_expiring_category_types.include? name end |
#non_expiring_category_types ⇒ Object
18 19 20 |
# File 'app/models/spree/store_credit_category.rb', line 18 def non_expiring_category_types DEFAULT_NON_EXPIRING_TYPES | Spree::Config[:non_expiring_credit_types] end |
#store_credit_category_used? ⇒ Boolean
22 23 24 |
# File 'app/models/spree/store_credit_category.rb', line 22 def store_credit_category_used? Spree::StoreCredit.exists?(category_id: id) end |
#validate_not_used ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/spree/store_credit_category.rb', line 26 def validate_not_used if store_credit_category_used? errors.add(:base, :cannot_destroy_if_used_in_store_credit) throw(:abort) end end |