Sha256: d1b812691ebcabd66fe622e70e2a829aa0af0b68296233eed09618c646881976
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
require_dependency "renalware/messaging" # A form object used behind the html messages#new form, and serving to helps us capture # attributes for a Message and its Recipients. The MessageForm is passed to the SendMessage # object where it is persisted as a Message with many Recipients through Receipts. module Renalware module Messaging class MessageForm include ActiveModel::Model include Virtus::Model attribute :body, String attribute :subject, String attribute :urgent, Boolean, default: false attribute :recipient_ids, Array, default: [] attribute :replying_to_message_id validates :body, presence: true validates :subject, presence: true validates :recipient_ids, presence: true, length: { minimum: 1 } def initialize(attributes = {}) remove_blank_recipient_ids_from(attributes) super end private def remove_blank_recipient_ids_from(params) params[:recipient_ids].reject!(&:blank?) if params.key?(:recipient_ids) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems