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
readonly
Returns the value of attribute result.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
- #===(other) ⇒ Boolean?
-
#[](key) ⇒ Object
Can be any type.
- #empty? ⇒ Boolean
- #has_attribute?(key) ⇒ Boolean
- #initialize(value:, result: nil) ⇒ void
- #keys ⇒ Array<Symbol>
- #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)
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/data/concern/instance_methods.rb', line 27 def result @result end |
#value ⇒ Object (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/data/concern/instance_methods.rb', line 21 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean?
77 78 79 80 81 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 77 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.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# 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 124 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.
148 149 150 |
# 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 148 def [](key) value.fetch(key.to_sym) { ::ConvenientService.raise Exceptions::NotExistingAttribute.new(attribute: key) } end |
#empty? ⇒ Boolean
54 55 56 |
# 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 54 def empty? value.empty? end |
#has_attribute?(key) ⇒ Boolean
62 63 64 |
# 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 62 def has_attribute?(key) value.has_key?(key.to_sym) end |
#initialize(value:, result: nil) ⇒ void
46 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 46 def initialize(value:, result: nil) @value = value @result = result end |
#keys ⇒ Array<Symbol>
69 70 71 |
# 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 69 def keys value.keys end |
#to_arguments ⇒ ConveninentService::Support::Arguments
162 163 164 |
# 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 162 def to_arguments @to_arguments ||= Support::Arguments.new(value: value, result: result) end |
#to_h ⇒ Hash
169 170 171 |
# 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 to_h @to_h ||= value.to_h end |
#to_kwargs ⇒ Hash{Symbol => Object}
155 156 157 |
# 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 155 def to_kwargs to_arguments.kwargs end |
#to_s ⇒ String
176 177 178 |
# 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 176 def to_s @to_s ||= to_h.to_s end |