Class: JSend::Response
- Inherits:
-
Object
- Object
- JSend::Response
- Defined in:
- lib/jsend/responses/response.rb
Instance Method Summary collapse
Instance Method Details
#error? ⇒ Boolean
19 20 21 |
# File 'lib/jsend/responses/response.rb', line 19 def error? @status == JSend::ERROR end |
#fail? ⇒ Boolean
15 16 17 |
# File 'lib/jsend/responses/response.rb', line 15 def fail? @status == JSend::FAIL end |
#success? ⇒ Boolean
11 12 13 |
# File 'lib/jsend/responses/response.rb', line 11 def success? @status == JSend::SUCCESS end |
#to_json ⇒ Object
5 6 7 8 9 |
# File 'lib/jsend/responses/response.rb', line 5 def to_json data = {status: @status, message: @message, code: @code, data: @data} relevant_data = data.keep_if { |_, v| !v.nil? } relevant_data.to_json end |