Class: Shaf::Responder::ProblemJson

Inherits:
Base
  • Object
show all
Defined in:
lib/shaf/responder/problem_json.rb

Constant Summary

Constants inherited from Base

Base::PRELOAD_FAILED_MSG

Instance Attribute Summary

Attributes inherited from Base

#controller, #options, #resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#build_response, call, #initialize, #lookup_rel, mime_type, #preload_links, #serialized_hash, use_as_default!

Constructor Details

This class inherits a constructor from Shaf::Responder::Base

Class Method Details

.can_handle?(resource) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/shaf/responder/problem_json.rb', line 6

def self.can_handle?(resource)
  klass = resource.is_a?(Class) ? resource : resource.class
  klass <= StandardError
end

Instance Method Details

#bodyObject



11
12
13
# File 'lib/shaf/responder/problem_json.rb', line 11

def body
  JSON.generate(hash)
end