Sha256: 97f96dd260f13144542411d7890ba47910c9ee581a5723f1774d0f7404a0e58a

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveSteps
        module Entities
          class Method
            module Commands
              ##
              # TODO: Abstract factory.
              #
              class CastMethodDirection < Support::Command
                attr_reader :other, :options

                def initialize(other:, options:)
                  @other = other
                  @options = options
                end

                def call
                  casted =
                    case options[:direction]
                    when ::Symbol then cast_symbol
                    when ::String then cast_string
                    end

                  ##
                  # TODO: Specs. Priority.
                  #
                  return casted if casted

                  case other
                  when Method then cast_method
                  end
                end

                private

                def cast_symbol
                  case options[:direction]
                  when :input
                    Entities::Directions::Input.new
                  when :output
                    Entities::Directions::Output.new
                  end
                end

                def cast_string
                  case options[:direction]
                  when "input"
                    Entities::Directions::Input.new
                  when "output"
                    Entities::Directions::Output.new
                  end
                end

                def cast_method
                  other.direction.copy
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convenient_service-0.11.0 lib/convenient_service/service/plugins/can_have_steps/entities/method/commands/cast_method_direction.rb