Sha256: 8182572f54d06534e2ca7a158c38607483dba3d190173bcea879132621da8989

Contents?: true

Size: 608 Bytes

Versions: 9

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module ActionTracker
  module Workers
    class UndefinedWorkerError < StandardError; end

    class Factory
      attr_reader :form

      def initialize(form)
        @form = form
      end

      def instance
        raise UndefinedWorkerError, tracking_method unless worker_klass

        worker_klass.new(form)
      end

      private

      def worker_klass
        @worker_klass ||= "ActionTracker::Workers::#{tracking_method.classify}".safe_constantize
      end

      def tracking_method
        ActionTracker.config.tracking_method.to_s
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
action_tracker_client-0.1.8 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.7 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.6 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.5 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.4 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.3 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.2 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.1 lib/action_tracker/workers/factory.rb
action_tracker_client-0.1.0 lib/action_tracker/workers/factory.rb