Class: Hippo::API::GenericController

Inherits:
ControllerBase show all
Defined in:
lib/hippo/api/generic_controller.rb

Instance Attribute Summary

Attributes inherited from ControllerBase

#data, #model, #params

Instance Method Summary collapse

Methods inherited from ControllerBase

#initialize

Methods included from FormattedReply

#json_status_str, #record_active_record_errors, #records_for_reply, #std_api_reply

Constructor Details

This class inherits a constructor from Hippo::API::ControllerBase

Instance Method Details

#createObject



11
12
13
14
15
# File 'lib/hippo/api/generic_controller.rb', line 11

def create
    record  = model.from_attribute_data(data, current_user)
    options = build_reply_options.merge(success: record.save)
    std_api_reply(:create, record, options)
end

#destroyObject



25
26
27
28
29
30
31
# File 'lib/hippo/api/generic_controller.rb', line 25

def destroy
    if params[:id]
        perform_single_destroy
    elsif data.is_a?(Array)
        perform_multiple_destroy
    end
end

#showObject



7
8
9
# File 'lib/hippo/api/generic_controller.rb', line 7

def show
    perform_retrieval
end

#updateObject



17
18
19
20
21
22
23
# File 'lib/hippo/api/generic_controller.rb', line 17

def update
    if params[:id]
        perform_single_update
    elsif data.is_a?(Array)
        perform_multiple_updates
    end
end