Sha256: 9d755352d77032759423b197d718057531e4c7ff6b1c2b4751522b4a941c2064

Contents?: true

Size: 995 Bytes

Versions: 6

Compression:

Stored size: 995 Bytes

Contents

module RailsConnector

  class ObjsController < ActionController::Base

    before_filter :restrict_non_allow_access

    respond_to :json

    def update
      raise "Required parameter 'obj' is missing." unless params[:obj].present?
      raise "Parameter 'obj' is not a hash." unless params[:obj].is_a?(Hash)

      begin
        changed_obj = CmsRestApi.put(
          "revisions/#{Workspace.current.revision_id}/objs/#{params[:id]}",
          { :obj => params[:obj] }
        )
        render :json => changed_obj
      rescue ClientError => e
        render :json => {:error => e.message}, :status => e.http_code
      end
    end

    private

    def restrict_non_allow_access
      unless allow_access?
        render(:text => 'Forbidden', :status => 403)
      end
    end

    # Overwrite this method in your project.
    # If +true+, allow access to ObjsController, else deny access.
    # Default: +false+
    # @return [Bool]
    def allow_access?
      false
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.1.26.236500544 app/controllers/rails_connector/objs_controller.rb
infopark_cloud_connector-6.8.1 app/controllers/rails_connector/objs_controller.rb
infopark_cloud_connector-6.8.0.539.93842523 app/controllers/rails_connector/objs_controller.rb
infopark_cloud_connector-6.8.0.529.114081979 app/controllers/rails_connector/objs_controller.rb
infopark_cloud_connector-6.8.0.518.30999728 app/controllers/rails_connector/objs_controller.rb
infopark_cloud_connector-6.8.0.515.34928522 app/controllers/rails_connector/objs_controller.rb