Sha256: c294c550a24228c319eac3c8dd06669dcc4fd7a60102b16df4e5f98ceef6ad19

Contents?: true

Size: 934 Bytes

Versions: 22

Compression:

Stored size: 934 Bytes

Contents

module Api
  class HooksController < BaseController
    require_permission :read, :hook, only: %i(index show)
    require_permission :write, :hook, only: %i(create update destroy)

    def index
      render_resources hooks
    end

    def show
      render json: hook
    end

    params do
      requires :url, String
      requires :events, Array[String]
      accepts :content_type, String
    end
    def create
      render_resource hooks.create(params)
    end

    params do
      accepts :url, String
      accepts :events, Array[String]
      accepts :content_type, String
    end
    def update
      hook.update(params)
      render_resource hook
    end

    def destroy
      render_resource hook.destroy
    end

    private

    def hook
      hooks.find(params[:id])
    end

    def hooks
      Hook.where(stack_id: stack_id)
    end

    def stack_id
      stack.id if params[:stack_id].present?
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
shipit-engine-0.5.2 app/controllers/api/hooks_controller.rb
shipit-engine-0.5.1 app/controllers/api/hooks_controller.rb
shipit-engine-0.5.0 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.10 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.9 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.8 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.7 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.6 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.5 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.4 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.3 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.2 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.1 app/controllers/api/hooks_controller.rb
shipit-engine-0.4.0 app/controllers/api/hooks_controller.rb
shipit-engine-0.3.1 app/controllers/api/hooks_controller.rb
shipit-engine-0.3.0 app/controllers/api/hooks_controller.rb
shipit-engine-0.2.3 app/controllers/api/hooks_controller.rb
shipit-engine-0.2.2 app/controllers/api/hooks_controller.rb
shipit-engine-0.2.1 app/controllers/api/hooks_controller.rb
shipit-engine-0.2.0 app/controllers/api/hooks_controller.rb