Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Inputs

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object:, method:, block_expectation:) ⇒ 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:

  • object (Object)
  • method (String, Symbol)
  • block_expectation (Proc)


26
27
28
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 26

def initialize(object:, method:, block_expectation:)
  @values = {object: object, method: method, block_expectation: block_expectation}
end

Instance Attribute Details

#valuesObject (readonly)

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.



16
17
18
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 16

def values
  @values
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)


210
211
212
213
214
215
216
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 210

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

  return false if values != other.values

  true
end

#block_expectationProc?

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:

  • (Proc, nil)


35
36
37
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 35

def block_expectation
  values[:block_expectation]
end

#block_expectation=(block) ⇒ Proc

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:

  • (Proc)


152
153
154
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 152

def block_expectation=(block)
  values[:block_expectation] = block
end

#custom_return_valueObject

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 Can be any type.

Returns:

  • (Object)

    Can be any type.



47
48
49
50
51
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 47

def custom_return_value
  return values[:custom_return_value] if values.has_key?(:custom_return_value)

  values[:custom_return_value] = expected_return_value_block.call(delegation_value)
end

#delegation_valueObject

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 Can be any type.

Returns:

  • (Object)

    Can be any type.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 61

def delegation_value
  return values[:delegation_value] if values.has_key?(:delegation_value)

  values[:delegation_value] =
    object.__send__(
      method,
      *expected_arguments.args,
      **expected_arguments.kwargs,
      &expected_arguments.block
    )
end

#expected_argumentsConvenientService::Support::Arguments

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.



78
79
80
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 78

def expected_arguments
  values[:expected_arguments] ||= Support::Arguments.null_arguments
end

#expected_arguments=(arguments) ⇒ ConvenientService::Support::Arguments

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.



162
163
164
165
166
167
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 162

def expected_arguments=(arguments)
  values.delete(:delegation_value)
  values.delete(:custom_return_value)

  values[:expected_arguments] = arguments
end

#expected_return_value_blockProc

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:

  • (Proc)


87
88
89
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 87

def expected_return_value_block
  values[:expected_return_value_block] ||= proc { Support::UNDEFINED }
end

#has_call_original?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.

Returns:

  • (Boolean)


132
133
134
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 132

def has_call_original?
  values.has_key?(:should_call_original)
end

#methodString, Symbol

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:

  • (String, Symbol)


96
97
98
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 96

def method
  values[:method]
end

#objectObject

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 Can be any type.

Returns:

  • (Object)

    Can be any type.



105
106
107
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 105

def object
  values[:object]
end

#printable_block_expectationString

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:

  • (String)


114
115
116
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 114

def printable_block_expectation
  @printable_block_expectation ||= Utils::Proc.display(block_expectation)
end

#printable_methodString

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:

  • (String)


123
124
125
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 123

def printable_method
  @printable_method ||= Commands::GeneratePrintableMethod.call(object: object, method: method)
end

#should_call_original=(flag) ⇒ 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:

  • flag (Boolean)

Returns:

  • (Boolean)


175
176
177
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 175

def should_call_original=(flag)
  values[:should_call_original] = flag
end

#should_call_original?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.

Returns:

  • (Boolean)


141
142
143
144
145
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 141

def should_call_original?
  return values[:should_call_original] if values.has_key?(:should_call_original)

  values[:should_call_original] = true
end

#update_expected_return_value_block(*args, &block) ⇒ Proc

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.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/inputs.rb', line 186

def update_expected_return_value_block(*args, &block)
  values.delete(:custom_return_value)

  values[:expected_return_value_block] =
    if args.any? && block
      ::ConvenientService.raise Exceptions::ReturnCustomValueChainingInvalidArguments.new
    elsif args.any?
      proc { args.first }
    elsif block
      block
    else
      ::ConvenientService.raise Exceptions::ReturnCustomValueChainingInvalidArguments.new
    end
end