Sha256: d893039a911da0c70248c8862ba3092481be6417fe31a58b3979be72da31e957

Contents?: true

Size: 606 Bytes

Versions: 4

Compression:

Stored size: 606 Bytes

Contents

# frozen_string_literal: true

module RespondForHelper
  module Formats
    class Json < Base
      self.format = :json

      def item_errors
        @item.errors
      end

      private

      def perform
        if @behaviour.render?
          perform_render
        elsif @behaviour.head?
          perform_head
        end
      end

      def perform_render
        render @behaviour.options.merge(json: resolve_target(@behaviour.target))
      end

      def perform_head
        head resolve_target(@behaviour.target), @behaviour.options
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
respond_for_helper-1.1.3 lib/respond_for_helper/formats/json.rb
respond_for_helper-1.1.2 lib/respond_for_helper/formats/json.rb
respond_for_helper-1.1.1 lib/respond_for_helper/formats/json.rb
respond_for_helper-1.1.0 lib/respond_for_helper/formats/json.rb