Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Concern::InstanceMethods
- Defined in:
- lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb
Overview
TODO: How to use concern outside?
Instance Method Summary collapse
- #==(other) ⇒ Boolean?
- #code ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code (also: #unsafe_code)
- #create_code(code) ⇒ Symbol
- #create_data(data) ⇒ Hash{Symbol => Object}
- #create_message(message) ⇒ String
- #create_status(status) ⇒ Symbol
- #data ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data (also: #unsafe_data)
- #error? ⇒ Boolean
- #extra_kwargs ⇒ Hash{Object => Symbol}
- #failure? ⇒ Boolean
- #jsend_attributes ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Structs::JSendAttributes
- #message ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message (also: #unsafe_message)
- #not_error? ⇒ Boolean
- #not_failure? ⇒ Boolean
- #not_success? ⇒ Boolean
- #service ⇒ Class
- #status ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status
- #success? ⇒ Boolean
-
#to_a ⇒ Array<ConvenientService::Support::Value>
Returns an array representation of ‘result`.
- #to_arguments ⇒ ConveninentService::Support::Arguments
-
#to_bool ⇒ Boolean
Returns a boolean representation of ‘result`.
-
#to_h ⇒ Hash{ConvenientService::Support::Value => ConvenientService::Support::Value}
Returns a hash representation of ‘result`.
- #to_kwargs ⇒ Hash{Symbol => Object}
-
#to_object ⇒ ConvenientService::Support::Value
Returns a boolean representation of ‘result`.
-
#to_s ⇒ String
Returns a string representation of ‘result`.
Methods included from ConvenientService::Support::Copyable
Methods included from ConvenientService::Support::Concern
Instance Method Details
#==(other) ⇒ Boolean?
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 136 def ==(other) return unless other.instance_of?(self.class) return false if service.class != other.service.class return false if status != other.status return false if unsafe_data != other.unsafe_data return false if != other. return false if unsafe_code != other.unsafe_code true end |
#code ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Code Also known as: unsafe_code
82 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 82 delegate :code, to: :jsend_attributes |
#create_code(code) ⇒ Symbol
125 126 127 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 125 def create_code(code) self.class.code(value: code, result: self) end |
#create_data(data) ⇒ Hash{Symbol => Object}
111 112 113 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 111 def create_data(data) self.class.data(value: data, result: self) end |
#create_message(message) ⇒ String
118 119 120 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 118 def () self.class.(value: , result: self) end |
#create_status(status) ⇒ Symbol
104 105 106 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 104 def create_status(status) self.class.status(value: status, result: self) end |
#data ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Data Also known as: unsafe_data
62 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 62 delegate :data, to: :jsend_attributes |
#error? ⇒ Boolean
32 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 32 delegate :error?, to: :status |
#extra_kwargs ⇒ Hash{Object => Symbol}
92 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 92 delegate :extra_kwargs, to: :jsend_attributes |
#failure? ⇒ Boolean
27 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 27 delegate :failure?, to: :status |
#jsend_attributes ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Structs::JSendAttributes
97 98 99 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 97 def jsend_attributes internals.cache[:jsend_attributes] end |
#message ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Message Also known as: unsafe_message
72 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 72 delegate :message, to: :jsend_attributes |
#not_error? ⇒ Boolean
47 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 47 delegate :not_error?, to: :status |
#not_failure? ⇒ Boolean
42 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 42 delegate :not_failure?, to: :status |
#not_success? ⇒ Boolean
37 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 37 delegate :not_success?, to: :status |
#service ⇒ Class
52 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 52 delegate :service, to: :jsend_attributes |
#status ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Entities::Status
57 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 57 delegate :status, to: :jsend_attributes |
#success? ⇒ Boolean
22 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 22 delegate :success?, to: :status |
#to_a ⇒ Array<ConvenientService::Support::Value>
This method is useful for learning purposes, to show similarities with Ruby’s objects. Please, do NOT depend on it in production.
Returns an array representation of ‘result`. `success` may be considered as array with items. `failure` may be considered as empty array. `error` may be considered as `raise exception`.
240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 240 def to_a case status.value when :success [Support::Value.new("item")] when :failure [] when :error raise ::ConvenientService.raise Exceptions::ErrorHasNoOtherTypeRepresentation.new(type: :array) else raise ::ConvenientService.raise Support::NeverReachHere.new(extra_message: "Unknown result status `#{status.value}`.") end end |
#to_arguments ⇒ ConveninentService::Support::Arguments
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 158 def to_arguments Support::Arguments.new( service: service, status: status, data: unsafe_data, message: , code: unsafe_code, **extra_kwargs ) end |
#to_bool ⇒ Boolean
This method is useful for learning purposes, to show similarities with Ruby’s booleans. Please, do NOT depend on it in production.
Returns a boolean representation of ‘result`. `success` may be considered as `true`. `failure` may be considered as `false`. `error` may be considered as `raise exception`.
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 184 def to_bool case status.value when :success true when :failure false when :error raise ::ConvenientService.raise Exceptions::ErrorHasNoOtherTypeRepresentation.new(type: :boolean) else raise ::ConvenientService.raise Support::NeverReachHere.new(extra_message: "Unknown result status `#{status.value}`.") end end |
#to_h ⇒ Hash{ConvenientService::Support::Value => ConvenientService::Support::Value}
This method is useful for learning purposes, to show similarities with Ruby’s objects. Please, do NOT depend on it in production.
Returns a hash representation of ‘result`. `success` may be considered as hash with items. `failure` may be considered as empty hash. `error` may be considered as `raise exception`.
268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 268 def to_h case status.value when :success {Support::Value.new("key") => Support::Value.new("value")} when :failure {} when :error raise ::ConvenientService.raise Exceptions::ErrorHasNoOtherTypeRepresentation.new(type: :hash) else raise ::ConvenientService.raise Support::NeverReachHere.new(extra_message: "Unknown result status `#{status.value}`.") end end |
#to_kwargs ⇒ Hash{Symbol => Object}
151 152 153 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 151 def to_kwargs to_arguments.kwargs end |
#to_object ⇒ ConvenientService::Support::Value
This method is useful for learning purposes, to show similarities with Ruby’s objects. Please, do NOT depend on it in production.
Returns a boolean representation of ‘result`. `success` may be considered as `object`. `failure` may be considered as `nil` (or null object). `error` may be considered as `raise exception`.
212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 212 def to_object case status.value when :success Support::Value.new("object") when :failure nil when :error raise ::ConvenientService.raise Exceptions::ErrorHasNoOtherTypeRepresentation.new(type: :object) else raise ::ConvenientService.raise Support::NeverReachHere.new(extra_message: "Unknown result status `#{status.value}`.") end end |
#to_s ⇒ String
This method is useful for learning purposes, to show similarities with Ruby’s objects. Please, do NOT depend on it in production.
Returns a string representation of ‘result`. `success` may be considered as string with content. `failure` may be considered as empty string. `error` may be considered as `raise exception`.
296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/has_j_send_status_and_attributes/concern/instance_methods.rb', line 296 def to_s case status.value when :success "string" when :failure "" when :error raise ::ConvenientService.raise Exceptions::ErrorHasNoOtherTypeRepresentation.new(type: :string) else raise ::ConvenientService.raise Support::NeverReachHere.new(extra_message: "Unknown result status `#{status.value}`.") end end |