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
Instance Method Summary collapse
- #apply(leadset:, message:) ⇒ Object
-
#field ⇒ Object
see WcoEmail::FIELD_*.
- #operator ⇒ Object
- #operator=(a) ⇒ Object
- #to_s ⇒ Object
- #to_s_full(indent: 0) ⇒ Object
Instance Method Details
#apply(leadset:, message:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/wco_email/email_filter_condition.rb', line 23 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 |
#field ⇒ Object
see WcoEmail::FIELD_*
12 |
# File 'app/models/wco_email/email_filter_condition.rb', line 12 field :field |
#operator ⇒ Object
17 |
# File 'app/models/wco_email/email_filter_condition.rb', line 17 def operator; matchtype; end |
#operator=(a) ⇒ Object
18 |
# File 'app/models/wco_email/email_filter_condition.rb', line 18 def operator= a; matchtype = a; end |
#to_s ⇒ Object
45 46 47 |
# File 'app/models/wco_email/email_filter_condition.rb', line 45 def to_s "<EFC #{field} #{matchtype} #{value} />" end |
#to_s_full(indent: 0) ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/models/wco_email/email_filter_condition.rb', line 48 def to_s_full indent: 0 _value = value if [ ::WcoEmail::OPERATOR_HAS_TAG, ::WcoEmail::OPERATOR_NOT_HAS_TAG ].include?( matchtype ) _value = Wco::Tag.find( value ) end "#{" " * indent }<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{matchtype} `#{_value}` />\n" end |