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, for_store, has_many_inversing, json_api_columns, json_api_permitted_attributes, json_api_type, page, spree_base_scopes, spree_base_uniqueness_scope
#clear_preferences, #default_preferences, #defined_preferences, #deprecated_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_deprecated, #preference_type, #set_preference
Class Method Details
.default_reimbursement_category(_options = {}) ⇒ Object
32
33
34
|
# File 'app/models/spree/store_credit_category.rb', line 32
def default_reimbursement_category(_options = {})
Spree::StoreCreditCategory.first
end
|
Instance Method Details
#non_expiring? ⇒ Boolean
12
13
14
|
# File 'app/models/spree/store_credit_category.rb', line 12
def non_expiring?
non_expiring_category_types.include? name
end
|
#non_expiring_category_types ⇒ Object
16
17
18
|
# File 'app/models/spree/store_credit_category.rb', line 16
def non_expiring_category_types
DEFAULT_NON_EXPIRING_TYPES | Spree::Config[:non_expiring_credit_types]
end
|
#store_credit_category_used? ⇒ Boolean
20
21
22
|
# File 'app/models/spree/store_credit_category.rb', line 20
def store_credit_category_used?
Spree::StoreCredit.exists?(category_id: id)
end
|
#validate_not_used ⇒ Object
24
25
26
27
28
29
|
# File 'app/models/spree/store_credit_category.rb', line 24
def validate_not_used
if store_credit_category_used?
errors.add(:base, :cannot_destroy_if_used_in_store_credit)
throw(:abort)
end
end
|