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_LEADSET =
'from-leadset'- FIELD_NOT_TAGGED =
'leadset-not-tagged'- FIELD_SUBJECT =
'subject'- FIELD_TAGGED =
'leadset-tagged'- FIELD_TO_OR_CC =
'to-or-cc'- FIELD_OPTS =
[ FIELD_BODY, FIELD_BODY_PLAIN, FIELD_FROM, FIELD_LEADSET, FIELD_NOT_TAGGED, FIELD_SUBJECT, FIELD_TAGGED, FIELD_TO_OR_CC, ]
- OPERATOR_EQUALS =
'eq-i'- OPERATOR_HAS_TAG =
'has-tag'- OPERATOR_NOT_HAS_TAG =
'not-has-tag'- OPERATOR_REGEX =
'regex'- OPERATOR_MATCH =
'match-i'- OPERATOR__ID =
'_id'- OPERATOR_SLUG =
'slug'- OPERATOR_OPTS =
[ OPERATOR__ID, OPERATOR_EQUALS, OPERATOR_HAS_TAG, OPERATOR_MATCH, OPERATOR_NOT_HAS_TAG, OPERATOR_REGEX, OPERATOR_SLUG, ]
Instance Method Summary collapse
Instance Method Details
#apply(leadset:, message:) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/models/wco_email/email_filter_condition.rb', line 53 def apply leadset:, message: cond = self reason = nil case cond.field ## from match-i <value> when WcoEmail::EmailFilterCondition::FIELD_FROM if cond.operator == WcoEmail::EmailFilterCondition::OPERATOR_MATCH if .from.downcase.include?( value.downcase ) reason = "#{email_skip_filter ? 'skip_' : ''}condition from match-i `#{value}`" end end end # when WcoEmail::FIELD_LEADSET # if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG # this_tag = Wco::Tag.find cond.value # if leadset.tags.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 message.to == cond.value # reason = "{email_skip_filter ? 'skip_' : ''}condition to = #{cond.value}" # end # end return reason end |
#to_s ⇒ Object
83 84 85 |
# File 'app/models/wco_email/email_filter_condition.rb', line 83 def to_s "<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{operator} `#{value}` />" end |
#to_s_full(indent: 0) ⇒ Object
86 87 88 |
# File 'app/models/wco_email/email_filter_condition.rb', line 86 def to_s_full indent: 0 "#{" " * indent }<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{operator} `#{value}` />\n" end |