Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::Concern::InstanceMethods Private

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/data/concern/instance_methods.rb

Overview

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

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConvenientService::Support::Copyable

#copy

Instance Attribute Details

#result ⇒ Object (readonly) Also known as: __result__

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.

Since:

  • 1.0.0



47
48
49
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 47

def result
  @result
end

#value ⇒ Object (readonly) Also known as: __value__

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.

Since:

  • 1.0.0



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

def value
  @value
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



173
174
175
176
177
178
179
180
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 173

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?

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.

Note:

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

Examples:

RSpec expectation matchers.

expect(result).to be_success.with_data(foo: match(/bar/))

RSpec mocks arguments matchers.

expect(result).to be_success.with_data(hash_including(:foo))

Combo of RSpec expectation matchers and RSpec mocks arguments.

expect(result).to be_success.with_data(hash_including(foo: match(/bar/)))

Parameters:

  • other (Object) —

    Can be any type.

Returns:

  • (Boolean, nil)

See Also:

Since:

  • 1.0.0



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 220

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

  return false if __result__.class != other.__result__.class

  ##
  # NOTE: Pattern matching is removed since it causes a huge and annoying warning in Ruby 2.7 apps. Users are too confused by it.
  #
  # TODO: Implement a Rubocop cop that forbids the usage of pattern matching until Ruby 2.7 is dropped.
  #
  if __value__.instance_of?(::Hash) && other.__value__.instance_of?(::Hash)
    return false unless Utils::Hash.triple_equality_compare(__value__, other.__value__)
  else
    return false unless __value__ === other.__value__
  end

  true
end

#[](key) ⇒ Object

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.

Parameters:

  • key (String, Symbol)

Returns:

  • (Object) —

    Can be any type.

Raises:

Since:

  • 1.0.0



151
152
153
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 151

def [](key)
  __value__.fetch(key.to_sym) { ::ConvenientService.raise Exceptions::NotExistingAttribute.new(attribute: key) }
end

#attributes ⇒ Hash{Symbol => Object} Also known as: __attributes__

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:

  • (Hash{Symbol => Object})

Since:

  • 1.0.0



110
111
112
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 110

def attributes
  __value__
end

#empty? ⇒ Boolean Also known as: __empty__?

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)

Since:

  • 1.0.0



82
83
84
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 82

def empty?
  __value__.empty?
end

#fetch(key, &block) ⇒ Object Also known as: __fetch__

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.

Parameters:

  • key (String, Symbol)

Returns:

  • (Object) —

    Can be any type.

Raises:

Since:

  • 1.0.0



160
161
162
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 160

def fetch(key, &block)
  __value__.fetch(key.to_sym) { block ? yield(self, key) : ::ConvenientService.raise(Exceptions::NotExistingAttribute.new(attribute: key)) }
end

#has_attribute?(key) ⇒ Boolean Also known as: __has_attribute__?

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:

  • key (String, Symbol)

Returns:

  • (Boolean)

Since:

  • 1.0.0



98
99
100
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 98

def has_attribute?(key)
  __value__.has_key?(key.to_sym)
end

#initialize(value:, result: nil) ⇒ 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



71
72
73
74
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 71

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

#keys ⇒ Array<Symbol> Also known as: __keys__

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:

  • (Array<Symbol>)

Since:

  • 1.0.0



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

def keys
  __value__.keys
end

#struct ⇒ Struct Also known as: __struct__

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:

  • (Struct)

Since:

  • 1.0.0



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

def struct
  @struct ||= ::Struct.new(*__value__.keys, keyword_init: true).new(__value__)
end

#to_arguments ⇒ ConveninentService::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.

Returns:

  • (ConveninentService::Support::Arguments)

Since:

  • 1.0.0



249
250
251
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 249

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

#to_h ⇒ Hash{Symbol => Object}

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:

  • (Hash{Symbol => Object})

Since:

  • 1.0.0



256
257
258
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 256

def to_h
  @to_h ||= __value__.to_h
end

#to_kwargs ⇒ Hash{Symbol => Object}

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:

  • (Hash{Symbol => Object})

Since:

  • 1.0.0



242
243
244
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 242

def to_kwargs
  to_arguments.kwargs
end

#to_s ⇒ String

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)

Since:

  • 1.0.0



263
264
265
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/entities/data/concern/instance_methods.rb', line 263

def to_s
  @to_s ||= __value__.to_h.to_s
end