Class: InstagramConnect::Result
- Inherits:
-
Object
- Object
- InstagramConnect::Result
- Defined in:
- lib/instagram_connect/result.rb
Overview
Value object returned by every Client call. Client methods never raise for
API-level failures — callers branch on success? and read error_code /
error_message. Transport/programming errors still raise.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
- .error(message, error_code: nil, retry_after: nil, data: {}) ⇒ Object
-
.ok(id: nil, data: {}) ⇒ Object
Convenience builders so call sites read cleanly.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(success:, id: nil, error_code: nil, error_message: nil, retry_after: nil, data: {}) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(success:, id: nil, error_code: nil, error_message: nil, retry_after: nil, data: {}) ⇒ Result
Returns a new instance of Result.
8 9 10 11 12 13 14 15 |
# File 'lib/instagram_connect/result.rb', line 8 def initialize(success:, id: nil, error_code: nil, error_message: nil, retry_after: nil, data: {}) @success = success @id = id @error_code = error_code @error_message = @retry_after = retry_after @data = data || {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def data @data end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def error_code @error_code end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def @error_message end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def id @id end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def retry_after @retry_after end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
6 7 8 |
# File 'lib/instagram_connect/result.rb', line 6 def success @success end |
Class Method Details
.error(message, error_code: nil, retry_after: nil, data: {}) ⇒ Object
30 31 32 |
# File 'lib/instagram_connect/result.rb', line 30 def self.error(, error_code: nil, retry_after: nil, data: {}) new(success: false, error_message: , error_code: error_code, retry_after: retry_after, data: data) end |
.ok(id: nil, data: {}) ⇒ Object
Convenience builders so call sites read cleanly.
26 27 28 |
# File 'lib/instagram_connect/result.rb', line 26 def self.ok(id: nil, data: {}) new(success: true, id: id, data: data) end |
Instance Method Details
#failure? ⇒ Boolean
21 22 23 |
# File 'lib/instagram_connect/result.rb', line 21 def failure? !success? end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/instagram_connect/result.rb', line 17 def success? success end |