Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data::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/data/concern/instance_methods.rb
Instance Attribute Summary collapse
- #result ⇒ Object (also: #__result__) readonly
- #value ⇒ Object (also: #__value__) readonly
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
- #===(other) ⇒ Boolean?
-
#[](key) ⇒ Object
Can be any type.
- #empty? ⇒ Boolean (also: #__empty__?)
- #has_attribute?(key) ⇒ Boolean (also: #__has_attribute__?)
- #initialize(value:, result: nil) ⇒ void
- #keys ⇒ Array<Symbol> (also: #__keys__)
- #to_arguments ⇒ ConveninentService::Support::Arguments
- #to_h ⇒ Hash
- #to_kwargs ⇒ Hash{Symbol => Object}
- #to_s ⇒ String
Methods included from ConvenientService::Support::Copyable
Instance Attribute Details
#result ⇒ Object (readonly) Also known as: __result__
43 44 45 |
# 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 43 def result @result end |
#value ⇒ Object (readonly) Also known as: __value__
29 30 31 |
# 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 29 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean?
122 123 124 125 126 127 128 129 |
# 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 122 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:
Data#===
allows to use RSpec expectation matchers and RSpec mocks arguments matchers for comparison.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# 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 169 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
Returns Can be any type.
193 194 195 |
# 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 193 def [](key) __value__.fetch(key.to_sym) { ::ConvenientService.raise Exceptions::NotExistingAttribute.new(attribute: key) } end |
#empty? ⇒ Boolean Also known as: __empty__?
78 79 80 |
# 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 78 def empty? __value__.empty? end |
#has_attribute?(key) ⇒ Boolean Also known as: __has_attribute__?
94 95 96 |
# 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 94 def has_attribute?(key) __value__.has_key?(key.to_sym) end |
#initialize(value:, result: nil) ⇒ void
67 68 69 70 |
# 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 67 def initialize(value:, result: nil) @value = value @result = result end |
#keys ⇒ Array<Symbol> Also known as: __keys__
109 110 111 |
# 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 109 def keys __value__.keys end |
#to_arguments ⇒ ConveninentService::Support::Arguments
207 208 209 |
# 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 207 def to_arguments @to_arguments ||= Support::Arguments.new(value: __value__, result: __result__) end |
#to_h ⇒ Hash
214 215 216 |
# 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 214 def to_h @to_h ||= __value__.to_h end |
#to_kwargs ⇒ Hash{Symbol => Object}
200 201 202 |
# 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 200 def to_kwargs to_arguments.kwargs end |
#to_s ⇒ String
221 222 223 |
# 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 221 def to_s @to_s ||= to_h.to_s end |