Sha256: b45f5c6e78f30aa439b7b347cc03f7350f23a9ebcf79bd3483c909096d17e7e6

Contents?: true

Size: 992 Bytes

Versions: 48

Compression:

Stored size: 992 Bytes

Contents

module Incline
  ##
  # Defines the message generated by the generic contact form.
  class ContactMessage
    include ActiveModel::Model
    include ActiveModel::Validations

    attr_accessor :your_name, :your_email, :related_to, :subject, :body, :remote_ip, :recaptcha

    validates :your_name, presence: true
    validates :your_email, presence: true, 'incline/email' => true
    validates :related_to, presence: true
    validates :subject, presence: true, if: :need_subject?
    validates :body, presence: true
    validates :recaptcha, presence: true, 'incline/recaptcha' => true

    ##
    # Gets the full subject for the message.
    def full_subject
      return related_to if subject.blank?
      "#{related_to}: #{subject}"
    end

    ##
    # Sends the message.
    def send_message
      Incline::ContactForm.contact(self).deliver_now
    end

    private

    def need_subject?
      related_to.to_s.downcase == 'other'
    end

  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 app/models/incline/contact_message.rb
incline-0.3.13 app/models/incline/contact_message.rb
incline-0.3.12 app/models/incline/contact_message.rb
incline-0.3.11 app/models/incline/contact_message.rb
incline-0.3.10 app/models/incline/contact_message.rb
incline-0.3.9 app/models/incline/contact_message.rb
incline-0.3.8 app/models/incline/contact_message.rb
incline-0.3.7 app/models/incline/contact_message.rb
incline-0.3.6 app/models/incline/contact_message.rb
incline-0.3.5 app/models/incline/contact_message.rb
incline-0.3.4 app/models/incline/contact_message.rb
incline-0.3.3 app/models/incline/contact_message.rb
incline-0.3.2 app/models/incline/contact_message.rb
incline-0.3.1 app/models/incline/contact_message.rb
incline-0.3.0 app/models/incline/contact_message.rb
incline-0.2.36 app/models/incline/contact_message.rb
incline-0.2.35 app/models/incline/contact_message.rb
incline-0.2.34 app/models/incline/contact_message.rb
incline-0.2.28 app/models/incline/contact_message.rb
incline-0.2.27 app/models/incline/contact_message.rb