Class: StandupMD::Post::Result
- Inherits:
-
Object
- Object
- StandupMD::Post::Result
- Defined in:
- lib/standup_md/post/result.rb
Overview
Result returned by posting adapters.
Instance Attribute Summary collapse
-
#adapter ⇒ Symbol
readonly
The adapter that handled the post.
-
#channel ⇒ String?
readonly
The destination channel, room, or conversation identifier.
-
#error ⇒ String?
readonly
Human-readable error message for failed posts.
-
#response ⇒ Hash
readonly
Adapter-specific response metadata.
Class Method Summary collapse
-
.failure(adapter:, channel:, error:, response: {}) ⇒ StandupMD::Post::Result
Builds a failed result.
-
.success(adapter:, channel:, response: {}) ⇒ StandupMD::Post::Result
Builds a successful result.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Did the post fail?.
-
#initialize(success:, adapter:, channel:, response: {}, error: nil) ⇒ Result
constructor
Builds a posting result.
-
#success? ⇒ Boolean
Was the post successful?.
Constructor Details
#initialize(success:, adapter:, channel:, response: {}, error: nil) ⇒ Result
Builds a posting result.
40 41 42 43 44 45 46 |
# File 'lib/standup_md/post/result.rb', line 40 def initialize(success:, adapter:, channel:, response: {}, error: nil) @success = success @adapter = adapter.to_sym @channel = channel @response = response @error = error end |
Instance Attribute Details
#adapter ⇒ Symbol (readonly)
The adapter that handled the post.
12 13 14 |
# File 'lib/standup_md/post/result.rb', line 12 def adapter @adapter end |
#channel ⇒ String? (readonly)
The destination channel, room, or conversation identifier.
18 19 20 |
# File 'lib/standup_md/post/result.rb', line 18 def channel @channel end |
#error ⇒ String? (readonly)
Human-readable error message for failed posts.
30 31 32 |
# File 'lib/standup_md/post/result.rb', line 30 def error @error end |
#response ⇒ Hash (readonly)
Adapter-specific response metadata.
24 25 26 |
# File 'lib/standup_md/post/result.rb', line 24 def response @response end |
Class Method Details
.failure(adapter:, channel:, error:, response: {}) ⇒ StandupMD::Post::Result
Builds a failed result.
60 61 62 63 64 65 66 67 68 |
# File 'lib/standup_md/post/result.rb', line 60 def self.failure(adapter:, channel:, error:, response: {}) new( success: false, adapter: adapter, channel: channel, response: response, error: error ) end |
.success(adapter:, channel:, response: {}) ⇒ StandupMD::Post::Result
Builds a successful result.
52 53 54 |
# File 'lib/standup_md/post/result.rb', line 52 def self.success(adapter:, channel:, response: {}) new(success: true, adapter: adapter, channel: channel, response: response) end |
Instance Method Details
#failure? ⇒ Boolean
Did the post fail?
82 83 84 |
# File 'lib/standup_md/post/result.rb', line 82 def failure? !success? end |
#success? ⇒ Boolean
Was the post successful?
74 75 76 |
# File 'lib/standup_md/post/result.rb', line 74 def success? @success end |