Sha256: 45c99177f6ea88042ec815870bc9340a71c82e84fe1c1a36fa6581d9bab8afcb

Contents?: true

Size: 862 Bytes

Versions: 9

Compression:

Stored size: 862 Bytes

Contents

module Spree
  module Countries
    class Find < ::Spree::BaseFinder
      def initialize(scope:, params:)
        @scope = scope

        @shippable = String(params[:filter][:shippable]) unless params[:filter].nil?
      end

      def call
        Spree::Deprecation.warn(<<-DEPRECATION, caller)
          Spree::Countries::Find.new.call is deprecated and will be removed in Spree 5.0.
          Please use Spree::Countries::Find.new.execute instead
        DEPRECATION
        execute
      end

      def execute
        countries = by_shippability(scope)

        countries
      end

      private

      attr_reader :shippable

      def shippable?
        shippable.present?
      end

      def by_shippability(countries)
        return countries unless shippable?

        countries.joins(zones: :shipping_methods).distinct
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/finders/spree/countries/find.rb
spree_core-4.10.0 app/finders/spree/countries/find.rb
spree_core-4.9.0 app/finders/spree/countries/find.rb
spree_core-4.8.3 app/finders/spree/countries/find.rb
spree_core-4.8.2 app/finders/spree/countries/find.rb
spree_core-4.7.3 app/finders/spree/countries/find.rb
spree_core-4.7.2 app/finders/spree/countries/find.rb
spree_core-4.7.1 app/finders/spree/countries/find.rb
spree_core-4.7.0 app/finders/spree/countries/find.rb