Sha256: aa00ebbcb3616e91b5b5d194240b4f6f9cb15bdeb032f37260d2f7216fb04245
Contents?: true
Size: 794 Bytes
Versions: 4
Compression:
Stored size: 794 Bytes
Contents
module Approval module RequestForm class Base include ::ActiveModel::Model attr_accessor :user, :reason, :records def initialize(user:, reason:, records:) @user = user @reason = reason @records = records end with_options presence: true do validates :user validates :reason, length: { maximum: Approval.config.comment_maximum } validates :records end def save return false unless valid? prepare(&:save) end def save! raise ::ActiveRecord::RecordInvalid unless valid? prepare(&:save!) 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