Sha256: 22c8ab733b199bdd27dd4acc339264cc98373a896f8029d1c46359baa684491a

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module CanHaveSteps
        module Entities
          class Service
            module Concern
              module ClassMethods
                ##
                # @param other [Object] Can be any type.
                # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Service, nil]
                #
                def cast(other)
                  case other
                  when ::Class then cast_klass(other)
                  when Service then cast_service(other)
                  end
                end

                private

                ##
                # @param klass [Class]
                # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Service]
                #
                def cast_klass(klass)
                  new(klass)
                end

                ##
                # @param service [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Service]
                # @return [ConvenientService::Service::Plugins::CanHaveSteps::Entities::Service]
                #
                def cast_service(service)
                  new(service.klass)
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.16.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb
convenient_service-0.13.0 lib/convenient_service/service/plugins/can_have_steps/entities/service/concern/class_methods.rb