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

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.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(status:, service_class: nil, arguments: nil, chain: {}) ⇒ 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



25
26
27
28
29
30
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 25

def initialize(status:, service_class: nil, arguments: nil, chain: {})
  @status = status
  @service_class = service_class
  @arguments = arguments
  @chain = chain
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



137
138
139
140
141
142
143
144
145
146
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 137

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

  return false if status != other.status
  return false if service_class != other.service_class
  return false if arguments != other.arguments
  return false if chain != other.chain

  true
end

#and_code(code) ⇒ 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.



95
96
97
98
99
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 95

def and_code(code)
  chain[:code] = code

  self
end

#and_data(data) ⇒ 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.



75
76
77
78
79
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 75

def and_data(data)
  chain[:data] = data

  self
end

#and_message(message) ⇒ 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:

  • message (String)

Returns:

Since:

  • 1.0.0



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

def and_message(message)
  chain[:message] = message

  self
end

#for(service_class, arguments) ⇒ 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.



37
38
39
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 37

def for(service_class, arguments)
  self.class.new(status: status, service_class: service_class, arguments: arguments, chain: chain)
end

#register(&block) ⇒ 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:

  • block (Proc, nil)

Returns:

Since:

  • 1.0.0



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 105

def register(&block)
  Commands::SetServiceStubbedResult[service: service_class, arguments: arguments, result: result]

  return self unless block

  begin
    yield
  ensure
    Commands::DeleteServiceStubbedResult[service: service_class, arguments: arguments]
  end
end

#resultConvenientService::Service

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.

Returns:

Since:

  • 1.0.0



129
130
131
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 129

def result
  service_class.__send__(status, **kwargs).copy(overrides: {kwargs: {stubbed_result: true}})
end

#unregisterConvenientService::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.



120
121
122
123
124
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 120

def unregister
  Commands::DeleteServiceStubbedResult[service: service_class, arguments: arguments]

  self
end

#with_code(code) ⇒ 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.



65
66
67
68
69
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 65

def with_code(code)
  chain[:code] = code

  self
end

#with_data(data) ⇒ 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.



45
46
47
48
49
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 45

def with_data(data)
  chain[:data] = data

  self
end

#with_message(message) ⇒ 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:

  • message (String)

Returns:

Since:

  • 1.0.0



55
56
57
58
59
# File 'lib/convenient_service/service/plugins/can_have_stubbed_results/entities/result_mock.rb', line 55

def with_message(message)
  chain[:message] = message

  self
end