Class: ConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ServiceStub Private

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(service_class:) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Since:

  • 1.0.0



21
22
23
24
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 21

def initialize(service_class:)
  @service_class = service_class
  @arguments = nil
end

Instance Method Details

#==(other) ⇒ Boolean?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



101
102
103
104
105
106
107
108
109
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 101

def ==(other)
  return unless other.instance_of?(self.class)

  return false if service_class != other.service_class
  return false if arguments != other.arguments
  return false if result_mock != other.result_mock

  true
end

#to(result_mock) ⇒ ConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ServiceStub

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



60
61
62
63
64
65
66
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 60

def to(result_mock)
  @result_mock = result_mock.for(service_class, arguments)

  @result_mock.register

  self
end

#to_return_errorConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ResultMock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



93
94
95
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 93

def to_return_error
  @result_mock = Entities::ResultMock.new(status: :error, service_class: service_class, arguments: arguments)
end

#to_return_failureConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ResultMock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 86

def to_return_failure
  @result_mock = Entities::ResultMock.new(status: :failure, service_class: service_class, arguments: arguments)
end

#to_return_result(status) ⇒ ConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ResultMock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • status (Symbol)

Returns:

Since:

  • 1.0.0



72
73
74
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 72

def to_return_result(status)
  @result_mock = Entities::ResultMock.new(status: status, service_class: service_class, arguments: arguments)
end

#to_return_successConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ResultMock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



79
80
81
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 79

def to_return_success
  @result_mock = Entities::ResultMock.new(status: :success, service_class: service_class, arguments: arguments)
end

#with_any_argumentsConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ServiceStub

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 32

def with_any_arguments(...)
  @arguments = nil

  self
end

#with_argumentsConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ServiceStub

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
45
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 41

def with_arguments(...)
  @arguments = Support::Arguments.new(...)

  self
end

#without_argumentsConvenientService::Service::Plugins::CanHaveStubbedResults::Entities::ServiceStub

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/service_stub.rb', line 50

def without_arguments
  @arguments = Support::Arguments.null_arguments

  self
end