Class: Spree::StoreCreditCategory
- Inherits:
-
Base
- Object
- ApplicationRecord
- Base
- Spree::StoreCreditCategory
show all
- 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
Methods inherited from Base
belongs_to_required_by_default, page, spree_base_scopes
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.default_reimbursement_category(_options = {}) ⇒ Object
30
31
32
|
# File 'app/models/spree/store_credit_category.rb', line 30
def default_reimbursement_category(_options = {})
Spree::StoreCreditCategory.first
end
|
Instance Method Details
#non_expiring? ⇒ Boolean
10
11
12
|
# File 'app/models/spree/store_credit_category.rb', line 10
def non_expiring?
non_expiring_category_types.include? name
end
|
#non_expiring_category_types ⇒ Object
14
15
16
|
# File 'app/models/spree/store_credit_category.rb', line 14
def non_expiring_category_types
DEFAULT_NON_EXPIRING_TYPES | Spree::Config[:non_expiring_credit_types]
end
|
#store_credit_category_used? ⇒ Boolean
18
19
20
|
# File 'app/models/spree/store_credit_category.rb', line 18
def store_credit_category_used?
Spree::StoreCredit.exists?(category_id: id)
end
|
#validate_not_used ⇒ Object
22
23
24
25
26
27
|
# File 'app/models/spree/store_credit_category.rb', line 22
def validate_not_used
if store_credit_category_used?
errors.add(:base, :cannot_destroy_if_used_in_store_credit)
throw(:abort)
end
end
|