Class: WcoEmail::EmailFilterCondition
- Inherits:
-
Object
- Object
- WcoEmail::EmailFilterCondition
- Includes:
- Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
- Defined in:
- app/models/wco_email/email_filter_condition.rb
Constant Summary collapse
- FIELD_BODY =
'body'- FIELD_BODY_PLAIN =
'body-plain'- FIELD_FROM =
'from'- FIELD_TAGGED =
'leadset-tagged'- FIELD_NOT_TAGGED =
'leadset-not-tagged'- FIELD_SUBJECT =
'subject'- FIELD_TO_OR_CC =
FIELD_TO = ‘to’
'to-or-cc'- FIELD_OPTS =
[ FIELD_SUBJECT, FIELD_FROM, FIELD_TO_OR_CC, FIELD_TAGGED, FIELD_NOT_TAGGED, FIELD_BODY, FIELD_BODY_PLAIN ]
- OPERATOR_EQUALS =
'eq-i'- OPERATOR_REGEX =
OPERATOR_HAS_TAG = ‘has-tag’ OPERATOR_NOT_HAS_TAG = ‘not-has-tag’
'regex'- OPERATOR_MATCH =
'match-i'- OPERATOR__ID =
'_id'- OPERATOR_SLUG =
'slug'- OPERATOR_OPTS =
[ OPERATOR_REGEX, OPERATOR_MATCH, OPERATOR__ID, OPERATOR_SLUG ]
Instance Method Summary collapse
Instance Method Details
#apply(leadset:, message:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/wco_email/email_filter_condition.rb', line 39 def apply leadset:, message: cond = self reason = nil case cond.field when WcoEmail::FIELD_LEADSET if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG this_tag = Wco::Tag.find cond.value if leadset..include?( this_tag ) ; else reason = "#{email_skip_filter ? 'skip_' : ''}condition leadset not-has-tag #{this_tag} NOT met" end end when WcoEmail::FIELD_TO if .to == cond.value reason = "{email_skip_filter ? 'skip_' : ''}condition to = #{cond.value}" end end return reason end |
#to_s ⇒ Object
61 62 63 |
# File 'app/models/wco_email/email_filter_condition.rb', line 61 def to_s "<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{operator} `#{value}` />" end |
#to_s_full(indent: 0) ⇒ Object
64 65 66 |
# File 'app/models/wco_email/email_filter_condition.rb', line 64 def to_s_full indent: 0 "#{" " * indent }<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{operator} `#{value}` />\n" end |