Sha256: 3b19e4343c2a704b05c05d38815dcc5733307624cd897f60a84ee13b72b2cbe8

Contents?: true

Size: 605 Bytes

Versions: 2

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true
module Pragma
  module Operation
    # Finds the requested record, authorizes it and decorates it.
    #
    # @author Alessandro Desantis
    class Show < Pragma::Operation::Base
      include Pragma::Operation::Defaults

      def call
        context.record = find_record
        authorize! context.record

        respond_with resource: decorate(context.record), status: :ok
      end

      protected

      # Finds the requested record.
      #
      # @return [Object]
      def find_record
        self.class.model_klass.find(params[:id])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pragma-1.2.6 lib/pragma/operation/show.rb
pragma-1.2.5 lib/pragma/operation/show.rb