Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code::Concern::InstanceMethods

Includes:
ConvenientService::Support::Copyable
Defined in:
lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConvenientService::Support::Copyable

#copy

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



32
33
34
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 32

def result
  @result
end

#valueObject (readonly)

Returns the value of attribute value.



26
27
28
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 26

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


48
49
50
51
52
53
54
55
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 48

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

  return false if result.class != other.result.class
  return false if value != other.value

  true
end

#===(other) ⇒ Boolean?

Note:

Code#=== allows to use RSpec expectation matchers and RSpec mocks arguments matchers for comparison.

Examples:

RSpec expectation matchers.

expect(result).to be_error.with_code(match(/bar/))

RSpec mocks arguments matchers.

expect(result).to be_success.with_code(instance_of(Symbol))

Just code does NOT work in case/when.


case result.code # `result.code` returns fancy object
when :full_queue
  notify_devops
when :duplicated_job
  notify_devs
else
  # ...
end

Code converted to symbol works in case/when.


case result.code.to_sym
when :full_queue
  notify_devops
when :duplicated_job
  notify_devs
else
  # ...
end

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

See Also:



105
106
107
108
109
110
111
112
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 105

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

  return false if result.class != other.result.class
  return false unless value === other.value

  true
end

#initialize(value:, result: nil) ⇒ void

Parameters:



39
40
41
42
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 39

def initialize(value:, result: nil)
  @value = value
  @result = result
end

#to_argumentsConveninentService::Support::Arguments

Returns:

  • (ConveninentService::Support::Arguments)


124
125
126
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 124

def to_arguments
  @to_arguments ||= Support::Arguments.new(value: value, result: result)
end

#to_kwargsHash{Symbol => Object}

Returns:

  • (Hash{Symbol => Object})


117
118
119
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 117

def to_kwargs
  to_arguments.kwargs
end

#to_sString

Returns:

  • (String)


131
132
133
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 131

def to_s
  @to_s ||= value.to_s
end

#to_symSymbol

Returns:

  • (Symbol)


138
139
140
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/code/concern/instance_methods.rb', line 138

def to_sym
  @to_sym ||= value.to_sym
end