Class: Spree::DeliveryZoneMember
- Inherits:
-
Object
- Object
- Spree::DeliveryZoneMember
- Defined in:
- app/models/spree/delivery_zone_member.rb
Constant Summary collapse
- MEMBER_TYPES =
%w[country state postal_code].freeze
Instance Method Summary collapse
-
#match?(address) ⇒ Boolean
A state member compares the country too: a subdivision code is only unique within its country, so "CA" alone would match California and several other places.
-
#postal_range? ⇒ Boolean
Whether this member defines a from/to range (vs a prefix).
Instance Method Details
#match?(address) ⇒ Boolean
A state member compares the country too: a subdivision code is only unique within its country, so "CA" alone would match California and several other places.
40 41 42 43 44 45 46 47 |
# File 'app/models/spree/delivery_zone_member.rb', line 40 def match?(address) case member_type when 'country' then same_country?(address) when 'state' then same_country?(address) && address.state_code.present? && address.state_code == state_code when 'postal_code' then same_country?(address) && postal_match?(address.normalized_postal_code) else false end end |
#postal_range? ⇒ Boolean
Returns whether this member defines a from/to range (vs a prefix).
50 51 52 |
# File 'app/models/spree/delivery_zone_member.rb', line 50 def postal_range? postal_code_from.present? || postal_code_to.present? end |