Sha256: d2418df594d9212c79642c73a6dd07fce2a404b61f5efc96fd2ceff835ccc476
Contents?: true
Size: 1.25 KB
Versions: 8
Compression:
Stored size: 1.25 KB
Contents
class WcoEmail::EmailFilterAction include Mongoid::Document include Mongoid::Timestamps store_in collection: 'email_filter_actions' belongs_to :email_filter KIND_EXE = 'exe' KIND_REMOVE_TAG = ::WcoEmail::ACTION_REMOVE_TAG KIND_ADD_TAG = ::WcoEmail::ACTION_ADD_TAG KIND_AUTORESPOND = ::WcoEmail::ACTION_AUTORESPOND KIND_SCHEDULE_EMAIL_ACTION = 'autorespond-email-action' KIND_REMOVE_EMAIL_ACTION = 'remove-email-action' field :kind validates :kind, inclusion: ::WcoEmail::ACTIONS field :value # the id of a tag, or email template, or email action before_validation :check_value def check_value case kind when KIND_AUTORESPOND existing = WcoEmail::EmailTemplate.where({ id: value }).first if !existing errors.add( :base, 'missing EmailTemplate id when creating an EmailFilterAction' ) throw :abort end end end def to_s "<EFA #{kind} #{value} />\n" end def to_s_full indent: 0 _value = value if [ KIND_ADD_TAG, KIND_REMOVE_TAG ].include?( kind ) _value = Wco::Tag.find( value ) end if [ KIND_AUTORESPOND ].include?( kind ) _value = WcoEmail::EmailTemplate.find( value ) end "#{" " * indent }<EFAction #{kind} `#{_value}` />\n" end end
Version data entries
8 entries across 8 versions & 1 rubygems