Class: Interchange::BaseController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Interchange::BaseController
- Defined in:
- app/controllers/interchange/base_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ BaseController
constructor
This constructor sets up a writer class, which we’ll use if we do any export for automation or export for later import purposes.
-
#show ⇒ Object
NOTE: This method is meant to be called by a subclass, that sets up the @model instance variable for us (along with other instance variables that the template we render would be expecting).
Constructor Details
#initialize ⇒ BaseController
This constructor sets up a writer class, which we’ll use if we do any export for automation or export for later import purposes. The writer handles the details of writing a model’s contents to disk.
5 6 7 8 |
# File 'app/controllers/interchange/base_controller.rb', line 5 def initialize super @writer = Interchange::Writer.new end |
Instance Method Details
#show ⇒ Object
NOTE: This method is meant to be called by a subclass, that sets up the
@model instance variable for us (along with other instance variables
that the template we render would be expecting).
14 15 16 17 18 |
# File 'app/controllers/interchange/base_controller.rb', line 14 def show pretty_json = render_show_template_to_string(@model, params) # Calls the two-parameter variant our subclasses should implement decorated_json = @writer.decorate_output(@model, pretty_json, params) render json: decorated_json end |