Sha256: 90211710176abe27811555cfc9bbdd4f897022e9d81ccba4bfa8524a86b7c57a

Contents?: true

Size: 525 Bytes

Versions: 4

Compression:

Stored size: 525 Bytes

Contents

# frozen_string_literal: true

require 'dry/equalizer'
require 'dry/effects/initializer'

module Dry
  module Effects
    class Effect
      extend Initializer

      include ::Dry::Equalizer(:type, :name, :payload)

      option :type

      option :name, default: -> { type }

      option :payload, default: -> { EMPTY_ARRAY }

      def payload(*payload)
        if payload.empty?
          @payload
        else
          with(payload: payload)
        end
      end
      alias_method :call, :payload
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-effects-0.1.1 lib/dry/effects/effect.rb
dry-effects-0.1.0 lib/dry/effects/effect.rb
dry-effects-0.1.0.alpha2 lib/dry/effects/effect.rb
dry-effects-0.1.0.alpha lib/dry/effects/effect.rb