Module: Roar::Rails::ControllerAdditions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/roar/rails/controller_additions.rb
Defined Under Namespace
Modules: ClassMethods Classes: RepresenterComputer
Instance Method Summary collapse
- #consume!(model, options = {}) ⇒ Object
- #prepare_model_for(format, model, options) ⇒ Object
-
#representer_for(format, model, options = {}) ⇒ Object
Central entry-point for finding the appropriate representer.
Instance Method Details
#consume!(model, options = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/roar/rails/controller_additions.rb', line 27 def consume!(model, ={}) format = formats.first # FIXME: i expected request.content_mime_type to do the job. copied from responder.rb. this will return the wrong format when the controller responds to :json and :xml and the Content-type is :xml (?) representer = prepare_model_for(format, model, ) representer.send(compute_parsing_method(format), incoming_string, ) # e.g. from_json("...") model end |
#prepare_model_for(format, model, options) ⇒ Object
35 36 37 38 |
# File 'lib/roar/rails/controller_additions.rb', line 35 def prepare_model_for(format, model, ) representer = representer_for(format, model, ) representer.prepare(model) end |
#representer_for(format, model, options = {}) ⇒ Object
Central entry-point for finding the appropriate representer.
41 42 43 |
# File 'lib/roar/rails/controller_additions.rb', line 41 def representer_for(format, model, ={}) .delete(:represent_with) || self.class..for(format, model, controller_path) end |