Class: Spree::CustomDomain
- Inherits:
-
Base
- Object
- Base
- Spree::CustomDomain
- Includes:
- Metadata, Metafields, SingleStoreResource
- Defined in:
- app/models/spree/custom_domain.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
- #ensure_default ⇒ Object
- #ensure_has_one_default ⇒ Object
- #name ⇒ Object
- #url_is_valid ⇒ Object
Instance Method Details
#active? ⇒ Boolean
46 47 48 |
# File 'app/models/spree/custom_domain.rb', line 46 def active? true end |
#ensure_default ⇒ Object
38 39 40 |
# File 'app/models/spree/custom_domain.rb', line 38 def ensure_default self.default = store.custom_domains.count.zero? end |
#ensure_has_one_default ⇒ Object
42 43 44 |
# File 'app/models/spree/custom_domain.rb', line 42 def ensure_has_one_default store.custom_domains.where.not(id: id).update_all(default: false) if default? end |
#name ⇒ Object
50 51 52 |
# File 'app/models/spree/custom_domain.rb', line 50 def name url end |
#url_is_valid ⇒ Object
31 32 33 34 35 36 |
# File 'app/models/spree/custom_domain.rb', line 31 def url_is_valid return if url.blank? parts = url.split('.') errors.add(:url, 'use domain or subdomain') if parts.size > 4 || parts.size < 2 end |