Sha256: 6d8928dcabaa6cc0e9e33a1fa420224295bd397de714e4078ca02ca2b10a4623

Contents?: true

Size: 549 Bytes

Versions: 10

Compression:

Stored size: 549 Bytes

Contents

# frozen_string_literal: true

module SolidusBolt
  class Sorter
    attr_reader :params

    def self.call(params)
      new(params).call
    end

    def initialize(params)
      @params = params
    end

    def call
      handler&.call(params)
    end

    private

    def handler
      class_name = "#{event_type.split('.').map(&:capitalize).join}Handler"

      return unless SolidusBolt::Handlers.const_defined?(class_name)

      SolidusBolt::Handlers.const_get(class_name)
    end

    def event_type
      params[:type]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.7.1 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.7.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.6.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.5.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.4.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.3.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.2.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.1.0 app/webhooks/solidus_bolt/sorter.rb
solidus_bolt-0.0.1 app/webhooks/solidus_bolt/sorter.rb