Sha256: b5c015ddecdd443c0c7be452d6656139624fa3d9681790ffbf6f897d964e1d94

Contents?: true

Size: 790 Bytes

Versions: 21

Compression:

Stored size: 790 Bytes

Contents

module Cmor::Contact
  class ContactRequest < ApplicationRecord
    validates :name, presence: true
    validates :email, presence: true
    validates :phone, presence: true
    validates :ip_address, presence: true
    validates :message, presence: true
    validates :accept_terms_of_service, acceptance: true

    module SpamProtection
      attr_accessor :nickname

      def save
        if nickname.present?
          valid?
          return true
        else
          super
        end
      end
    end

    module Notification
      def self.included(base)
        base.after_save :notify, if: -> { notified_at.nil? }
      end

      def notify
        NotifyNewContactRequestJob.perform_later(id)
      end
    end

    prepend SpamProtection
    include Notification
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cmor_contact-0.0.22.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.21.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.20.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.19.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.18.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.17.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.15.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.14.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.13.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.12.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.11.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.10.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.9.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.8.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.7.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.6.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.5.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.4.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.3.pre app/models/cmor/contact/contact_request.rb
cmor_contact-0.0.2.pre app/models/cmor/contact/contact_request.rb