Module: ConvenientService::Service::Plugins::HasJSendResult::Entities::Result::Plugins::HelpsToLearnSimilaritiesWithCommonObjects::Concern::InstanceMethods
- Defined in:
- lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb
Instance Method Summary collapse
-
#to_a ⇒ Array<ConvenientService::Support::Value>
Returns an array representation of
result. -
#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_object ⇒ ConvenientService::Support::Value
Returns a boolean representation of
result. -
#to_s ⇒ String
Returns a string representation of
result.
Instance Method Details
#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.
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb', line 89 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_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.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb', line 33 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.
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb', line 117 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_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.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb', line 61 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.
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/convenient_service/service/plugins/has_j_send_result/entities/result/plugins/helps_to_learn_similarities_with_common_objects/concern/instance_methods.rb', line 145 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 |