Class: Spree::Tax::TaxLocation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(country: nil, state: nil) ⇒ Spree::Tax::TaxLocation

Create a new TaxLocation object

Parameters:

  • country (Spree::Country) (defaults to: nil)

    a Spree::Country object, default: nil

  • state (Spree::State) (defaults to: nil)

    a Spree::State object, default: nil

See Also:

  • Zone.for_address


21
22
23
# File 'app/models/spree/tax/tax_location.rb', line 21

def initialize(country: nil, state: nil)
  @country, @state = country, state
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



11
12
13
# File 'app/models/spree/tax/tax_location.rb', line 11

def country
  @country
end

#country_idInteger (readonly)

the ID of a Spree::Country object

Returns:

  • (Integer)

    the current value of country_id



10
11
12
# File 'app/models/spree/tax/tax_location.rb', line 10

def country_id
  @country_id
end

#stateObject (readonly)

Returns the value of attribute state.



11
12
13
# File 'app/models/spree/tax/tax_location.rb', line 11

def state
  @state
end

#state_idInteger (readonly)

the ID of a Spree::State object

Returns:

  • (Integer)

    the current value of state_id



10
11
12
# File 'app/models/spree/tax/tax_location.rb', line 10

def state_id
  @state_id
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'app/models/spree/tax/tax_location.rb', line 27

def ==(other)
  state_id == other.state_id && country_id == other.country_id
end

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/spree/tax/tax_location.rb', line 31

def empty?
  country_id.nil? && state_id.nil?
end