Sha256: 45c19a897fe73e3f92b9f881698f354161628b1a5550c1f32ee66f4e5eb7ab8d

Contents?: true

Size: 1.11 KB

Versions: 46

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Spree
  module Tax
    # A class exclusively used as a drop-in replacement for a default tax address.
    # It responds to `:country_id` and `:state_id`.
    #
    # @attr_reader [Integer] country_id the ID of a Spree::Country object
    # @attr_reader [Integer] state_id the ID of a Spree::State object
    class TaxLocation
      attr_reader :country, :state

      # Create a new TaxLocation object
      #
      # @see Spree::Zone.for_address
      #
      # @param [Spree::Country] country a Spree::Country object, default: nil
      # @param [Spree::State] state a Spree::State object, default: nil
      #
      # @return [Spree::Tax::TaxLocation] a Spree::Tax::TaxLocation object
      def initialize(country: nil, state: nil)
        @country, @state = country, state
      end
      delegate :id, to: :state, prefix: true, allow_nil: true
      delegate :id, to: :country, prefix: true, allow_nil: true

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

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

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
solidus_core-4.4.1 app/models/spree/tax/tax_location.rb
solidus_core-4.4.0 app/models/spree/tax/tax_location.rb
solidus_core-4.3.4 app/models/spree/tax/tax_location.rb
solidus_core-4.2.4 app/models/spree/tax/tax_location.rb
solidus_core-4.1.5 app/models/spree/tax/tax_location.rb
solidus_core-4.3.3 app/models/spree/tax/tax_location.rb
solidus_core-4.3.2 app/models/spree/tax/tax_location.rb
solidus_core-4.1.4 app/models/spree/tax/tax_location.rb
solidus_core-4.3.1 app/models/spree/tax/tax_location.rb
solidus_core-4.3.0 app/models/spree/tax/tax_location.rb
solidus_core-4.2.3 app/models/spree/tax/tax_location.rb
solidus_core-4.1.3 app/models/spree/tax/tax_location.rb
solidus_core-4.0.4 app/models/spree/tax/tax_location.rb
solidus_core-3.4.6 app/models/spree/tax/tax_location.rb
solidus_core-4.0.3 app/models/spree/tax/tax_location.rb
solidus_core-4.1.2 app/models/spree/tax/tax_location.rb
solidus_core-4.2.2 app/models/spree/tax/tax_location.rb
solidus_core-3.4.5 app/models/spree/tax/tax_location.rb
solidus_core-4.2.1 app/models/spree/tax/tax_location.rb
solidus_core-4.2.0 app/models/spree/tax/tax_location.rb