Module: Easy::Api::ControllerMethods::InstanceMethods

Defined in:
lib/easy/api/controller_methods.rb

Instance Method Summary collapse

Instance Method Details

#render_formatObject

Renders the Easy::Api::Result object in either json or html format (can be extended to include other formats)



5
6
7
8
9
10
# File 'lib/easy/api/controller_methods.rb', line 5

def render_format
  respond_to do |format|
    format.html { render :status => @result.status_code }
    format.json { render :json => @result, :status => @result.status_code }
  end
end

#setup_resultObject

Initialises a new Easy::Api::Result object (@result) for your controller actions

Returns:

  • Easy::Api::Result



14
15
16
# File 'lib/easy/api/controller_methods.rb', line 14

def setup_result
  @result = Easy::Api::Result.new
end