Sha256: ef3ab9e05c94551e81c9087bcf0c9474d4882b36c0cc2626ac7bf86fda3d386c

Contents?: true

Size: 563 Bytes

Versions: 16

Compression:

Stored size: 563 Bytes

Contents

module Railjet
  module Util
    module FormHelper
      def form(klass)
        klass.new(clean_params).tap(&:validate!)
      end

      private

      def object_params
        raise NotImplementedError
      end

      def clean_params
        object_params
      end

      def respond_with_errors(object_with_errors, status: :unprocessable_entity)
        raise ArgumentError unless object_with_errors.respond_to?(:errors)

        response = object_with_errors.errors.to_hash(true)
        render json: response, status: status
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
railjet-4.0.0 lib/railjet/util/form_helper.rb
railjet-3.5.0 lib/railjet/util/form_helper.rb
railjet-3.4.0 lib/railjet/util/form_helper.rb
railjet-3.3.0 lib/railjet/util/form_helper.rb
railjet-3.2.0 lib/railjet/util/form_helper.rb
railjet-3.1.0 lib/railjet/util/form_helper.rb
railjet-3.0.0 lib/railjet/util/form_helper.rb
railjet-2.1.1 lib/railjet/util/form_helper.rb
railjet-2.1 lib/railjet/util/form_helper.rb
railjet-2.0 lib/railjet/util/form_helper.rb
railjet-2.0.pre4 lib/railjet/util/form_helper.rb
railjet-2.0.pre3 lib/railjet/util/form_helper.rb
railjet-2.0.pre2 lib/railjet/util/form_helper.rb
railjet-2.0.pre1 lib/railjet/util/form_helper.rb
railjet-2.0.pre lib/railjet/util/form_helper.rb
railjet-1.0.1 lib/railjet/util/form_helper.rb