Sha256: 4157e0879ebfe4d548d780a11bcad747ae2508895ed5f546f419c408ab7c4418

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

require 'reactive_record/server_data_cache'

module ReactiveRecord

  class ReactiveRecordController < ::ApplicationController

    def fetch
      render :json => ReactiveRecord::ServerDataCache[
        (params[:models] || []).map(&:with_indifferent_access),
        (params[:associations] || []).map(&:with_indifferent_access),
        params[:pending_fetches],
        acting_user
      ]
    rescue Exception => e
      render json: {error: e.message, backtrace: e.backtrace}, status: 500
    end

    def save
      render :json => ReactiveRecord::Base.save_records(
        (params[:models] || []).map(&:with_indifferent_access),
        (params[:associations] || []).map(&:with_indifferent_access),
        acting_user,
        params[:validate],
        true
      )
    rescue Exception => e
      render json: {error: e.message, backtrace: e.backtrace}, status: 500
    end

    def destroy
      render :json => ReactiveRecord::Base.destroy_record(
        params[:model],
        params[:id],
        params[:vector],
        acting_user
      )
    rescue Exception => e
      render json: {error: e.message, backtrace: e.backtrace}, status: 500
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reactive-record-0.7.43 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.42 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.41 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.40 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.39 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.38 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.37 app/controllers/reactive_record/reactive_record_controller.rb
reactive-record-0.7.36 app/controllers/reactive_record/reactive_record_controller.rb