Class: Intermodal::ResourceResponder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- Intermodal::ResourceResponder
- Includes:
- Let
- Defined in:
- lib/intermodal/responders/resource_responder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(controller, resources, options = {}) ⇒ ResourceResponder
constructor
A new instance of ResourceResponder.
-
#respond ⇒ Object
This is the common behavior for “API” requests, like :xml and :json.
Constructor Details
#initialize(controller, resources, options = {}) ⇒ ResourceResponder
Returns a new instance of ResourceResponder.
16 17 18 19 |
# File 'lib/intermodal/responders/resource_responder.rb', line 16 def initialize(controller, resources, ={}) super(controller, resources, ) @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/intermodal/responders/resource_responder.rb', line 8 def @options end |
Instance Method Details
#respond ⇒ Object
This is the common behavior for “API” requests, like :xml and :json.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/intermodal/responders/resource_responder.rb', line 22 def respond return head :status => 404 unless resource if get? display resource, root: presentation_root, presenter: presenter, scope: presentation_scope, always_nest_collections: always_nest_collections elsif has_errors? display resource.errors, root: presentation_root, status: :unprocessable_entity, presenter: presenter, scope: presentation_scope, always_nest_collections: always_nest_collections elsif put? display resource, root: presentation_root, presenter: presenter, scope: presentation_scope, always_nest_collections: always_nest_collections elsif post? display resource, root: presentation_root, status: :created, presenter: presenter, scope: presentation_scope, always_nest_collections: always_nest_collections #:location => api_location # Taken out because it requires some additional URL definitions else head status: 204 end end |