Class: InvisibleCollector::Response
- Inherits:
-
Object
- Object
- InvisibleCollector::Response
- Defined in:
- lib/invisible_collector/response.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
-
#error? ⇒ Boolean
true if the request failed for some reason.
-
#initialize(response, content) ⇒ Response
constructor
A new instance of Response.
-
#presence ⇒ Object
Returns the content of the response if the request was successful otherwise return
nil
. -
#success? ⇒ Boolean
true if the request was executed successfully.
Constructor Details
#initialize(response, content) ⇒ Response
Returns a new instance of Response.
7 8 9 10 |
# File 'lib/invisible_collector/response.rb', line 7 def initialize(response, content) @success = response.success? @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/invisible_collector/response.rb', line 5 def content @content end |
Instance Method Details
#error? ⇒ Boolean
true if the request failed for some reason
15 16 17 |
# File 'lib/invisible_collector/response.rb', line 15 def error? !@success end |
#presence ⇒ Object
Returns the content of the response if the request was successful otherwise return nil
. response.presence
is equivalent to
response.present? ? response.content : nil
26 27 28 |
# File 'lib/invisible_collector/response.rb', line 26 def presence @content if success? end |
#success? ⇒ Boolean
true if the request was executed successfully
33 34 35 |
# File 'lib/invisible_collector/response.rb', line 33 def success? @success end |