Class: Fson::Response
Class Method Summary collapse
- .error ⇒ Object
- .fail ⇒ Object
-
.success ⇒ Object
Factory Methods.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(status = nil) ⇒ Response
constructor
Constructor.
Methods included from Builder
#add_error, #data, #error, #fail, #status, #success
Constructor Details
#initialize(status = nil) ⇒ Response
Constructor
15 16 17 18 19 20 21 22 23 |
# File 'lib/fson/response.rb', line 15 def initialize(status = nil) @_response = {} @_data = nil @_errors = [] unless status.nil? @_response[:status] = status end end |
Class Method Details
.error ⇒ Object
43 44 45 |
# File 'lib/fson/response.rb', line 43 def error ::Fson::Response.new(:error) end |
.fail ⇒ Object
47 48 49 |
# File 'lib/fson/response.rb', line 47 def fail ::Fson::Response.new(:fail) end |
.success ⇒ Object
Factory Methods
39 40 41 |
# File 'lib/fson/response.rb', line 39 def success ::Fson::Response.new(:success) end |
Instance Method Details
#as_json ⇒ Object
25 26 27 |
# File 'lib/fson/response.rb', line 25 def as_json ::Oj.dump(build, :mode => :compat) end |