Sha256: 64d67b38bbb46bbca9a87d3fc40799e431f8ebb1b3e629bffc790b11cd030da7

Contents?: true

Size: 1.24 KB

Versions: 16

Compression:

Stored size: 1.24 KB

Contents

module Salestation
  class App
    class Request
      def self.create(env:, input:, initialize_hook: nil, span: nil)
        new(
          env: env,
          input: input,
          initialize_hook: initialize_hook,
          span: span
        ).to_success
      end

      attr_reader :env, :input, :span

      def with_input(input_additions)
        replace_input(input.merge(input_additions))
      end

      def replace_input(new_input)
        self.class.new(
          env: env,
          input: new_input,
          initialize_hook: @initialize_hook,
          span: span
        ).to_success
      end

      def to_success
        Deterministic::Result::Success(self)
      end

      def to_failure(input)
        Deterministic::Result::Failure(input)
      end

      # Initializes an asynchronous application hook
      #
      # Set a listener on App instance to receive a notification when the
      # asynchronous process completes.
      def initialize_hook(hook, payload)
        @initialize_hook.call(hook, payload)
      end

      private

      def initialize(env:, input:, initialize_hook: nil, span: nil)
        @env = env
        @input = input
        @initialize_hook = initialize_hook
        @span = span
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
salestation-1.0.2 lib/salestation/app/request.rb
salestation-1.0.1 lib/salestation/app/request.rb
salestation-1.0.0 lib/salestation/app/request.rb
salestation-0.13.0 lib/salestation/app/request.rb
salestation-0.12.0 lib/salestation/app/request.rb
salestation-0.11.0 lib/salestation/app/request.rb
salestation-0.10.0 lib/salestation/app/request.rb
salestation-0.9.0 lib/salestation/app/request.rb
salestation-0.8.0 lib/salestation/app/request.rb
salestation-0.7.0 lib/salestation/app/request.rb
salestation-0.6.0 lib/salestation/app/request.rb
salestation-0.5.0 lib/salestation/app/request.rb
salestation-0.4.0 lib/salestation/app/request.rb
salestation-0.3.0 lib/salestation/app/request.rb
salestation-0.2.1 lib/salestation/app/request.rb
salestation-0.2.0 lib/salestation/app/request.rb