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.



27
28
29
# 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 27

def result
  @result
end

#valueObject (readonly)

Returns the value of attribute value.



21
22
23
# 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 21

def value
  @value
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


43
44
45
46
47
48
49
50
# 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 43

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:



100
101
102
103
104
105
106
107
# 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 100

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:



34
35
36
37
# 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 34

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

#to_argumentsConveninentService::Support::Arguments

Returns:

  • (ConveninentService::Support::Arguments)


119
120
121
# 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 119

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

#to_kwargsHash{Symbol => Object}

Returns:

  • (Hash{Symbol => Object})


112
113
114
# 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 112

def to_kwargs
  to_arguments.kwargs
end

#to_sString

Returns:

  • (String)


126
127
128
# 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 126

def to_s
  @to_s ||= value.to_s
end

#to_symSymbol

Returns:

  • (Symbol)


133
134
135
# 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 133

def to_sym
  @to_sym ||= value.to_sym
end