Class: Spree::Tax::TaxLocation
- Inherits:
-
Object
- Object
- Spree::Tax::TaxLocation
- Defined in:
- app/models/spree/tax/tax_location.rb
Overview
A class exclusively used as a drop-in replacement for a default tax address. It responds to ‘:country_id` and `:state_id`.
Instance Attribute Summary collapse
-
#country_id ⇒ Integer
readonly
the ID of a Spree::Country object.
-
#state_id ⇒ Integer
readonly
the ID of a Spree::State object.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #country ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(country: nil, state: nil) ⇒ Spree::Tax::TaxLocation
constructor
Create a new TaxLocation object.
Constructor Details
#initialize(country: nil, state: nil) ⇒ Spree::Tax::TaxLocation
Create a new TaxLocation object
21 22 23 24 |
# File 'app/models/spree/tax/tax_location.rb', line 21 def initialize(country: nil, state: nil) @country_id = country && country.id @state_id = state && state.id end |
Instance Attribute Details
#country_id ⇒ Integer (readonly)
the ID of a Spree::Country object
10 11 12 |
# File 'app/models/spree/tax/tax_location.rb', line 10 def country_id @country_id end |
#state_id ⇒ Integer (readonly)
the ID of a Spree::State object
10 11 12 |
# File 'app/models/spree/tax/tax_location.rb', line 10 def state_id @state_id end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'app/models/spree/tax/tax_location.rb', line 26 def ==(other) state_id == other.state_id && country_id == other.country_id end |
#country ⇒ Object
30 31 32 |
# File 'app/models/spree/tax/tax_location.rb', line 30 def country Spree::Country.find_by(id: country_id) end |
#empty? ⇒ Boolean
34 35 36 |
# File 'app/models/spree/tax/tax_location.rb', line 34 def empty? country_id.nil? && state_id.nil? end |