Sha256: 0bee9fed4d8c9146b9ede949dfd841fd83fd24684e339049523a66827ff70467

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasResultSteps
        module Entities
          class Method
            module Commands
              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

7 entries across 7 versions & 1 rubygems

Version Path
convenient_service-0.5.0 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.4.0 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.3.1 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.2.0 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb
convenient_service-0.1.0 lib/convenient_service/service/plugins/has_result_steps/entities/method/commands/cast_method_direction.rb