Sha256: 4e8c4b9a1ea4b3dc1cfd3fb27347326f3c8433c8f94dfbc6e6495c081c494a4a

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Clubhouse
  module Concerns
    module Controllers
      module InvitationsController
        extend ActiveSupport::Concern

        def index
          render_list(authorize!(scoped))
        end

        def create
          invitation = authorize!(scoped.build)

          CreateInvitation.call({
            invitation: invitation,
            params: whitelist(invitation)
          })

          render json: invitation, status: :created
        end

        def show
          invitation = authorize!(fetch_invitation)
          render json: invitation, status: :ok
        end

        def update
          invitation = authorize!(fetch_invitation)
          invitation.update!(whitelist(invitation))
          render json: invitation, status: :ok
        end

        def destroy
          invitation = authorize!(fetch_invitation)
          invitation.destroy
          head :no_content
        end

        private
        def scoped
          Organization.locate!(params[:organization_id]).invitations
        end

        def fetch_invitation
          Invitation.find(params[:id])
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clubhouse-0.3.0 lib/clubhouse/concerns/controllers/invitations_controller.rb
clubhouse-0.2.0 lib/clubhouse/concerns/controllers/invitations_controller.rb
clubhouse-0.1.0 lib/clubhouse/concerns/controllers/invitations_controller.rb