Sha256: 824bccd3f3c16c412af57ad66b70dcea0c752a21d87b25bbc84451acc30360d0
Contents?: true
Size: 1013 Bytes
Versions: 4
Compression:
Stored size: 1013 Bytes
Contents
module Approval module RequestForm class Base include ::ActiveModel::Model include ::Approval::FormNotifiable attr_accessor :user, :reason, :records def initialize(user:, reason:, records:) @user = user @reason = reason @records = records end validates :user, presence: true validates :reason, presence: true, length: { maximum: Approval.config.comment_maximum } validates :records, presence: true def save return false unless valid? prepare(&:save) end def save! raise ::ActiveRecord::RecordInvalid unless valid? prepare(&:save!) end def request @request ||= user.approval_requests.new end def error_full_messages [errors, request.errors].flat_map(&:full_messages) end private def prepare raise NotImplementedError, "you must implement #{self.class}##{__method__}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems